35

I am using GitHub for Mac, and have bunch of changes in my branch. I am have committed some of the changes and kept others as uncommitted as I am expecting some more changes. however, when I try to do sync in order to push those changes to Git repository it complains - 'Uncommitted Changes - Please commit all your changes before syncing.'

Any idea? does it expects all the changes to be committed all the time when you do sync?

Mutant
  • 3,663
  • 4
  • 33
  • 53
  • Are you using "sync" as a synonym for "pull"? – chroipahtz Feb 26 '12 at 03:50
  • sync is specific to Github for Mac, and I *believe* it does pull and push. – Waynn Lue Feb 26 '12 at 04:05
  • Daenyth..thanks for feedback, @Chroipahtz - sync is from Github for Mac. though if there is any command which i can use to push single file please feel free to suggest. – Mutant Feb 26 '12 at 04:24
  • 1
    @Waynn Lue you are right, push+pull. But 'sync' is used in the exact same way in the GitHub client for Windows, so in that way it is not specific for Mac :). The thing is that in the Windows client you CAN sync with local uncommitted changes still there. Which is why this was so confusing to me at first. – Bart Nov 15 '13 at 08:58

2 Answers2

89

Rather than "syncing" your changes, GitHub for Mac does offer you the ability to push, pull and sync changes. Unfortunately, the UI button is for sync only. However, if you go to the menu bar, under "Repository" you see there are two additional changes: push (command + P) or pull (shift + command + P).

Curley
  • 1,621
  • 15
  • 13
  • The UI for that is confusing - esp for users who are new to the mac client. +1 for the keyboard shortcut. – Jay Sidri Oct 30 '13 at 23:41
  • Life saviour mate! What was the harm in adding just two more buttons to Github that make so much sense !!! Thanks a ton – sb_269 Jun 13 '14 at 05:04
2

Since I believe sync does both git pull and git push, it's trying to pull and merge changes from the remote repository to your local branch. If you want to successfully sync your changes with uncommitted local changes, you should stash your changes, do sync, and then unstash your changes. Remember, if there are conflicting changes when you unstash, you'll have to figure out the correct way to merge them.

edit: Under Repository, you can do push (Cmd + P) or pull (Shift + Cmd + P).

Waynn Lue
  • 11,344
  • 8
  • 51
  • 76
  • ok..Is there any manual way i can push a single file from git command line? – Mutant Feb 26 '12 at 04:27
  • @Mutant - you push always **not file**, but *changeset* – Lazy Badger Feb 26 '12 at 06:26
  • Right, so because of what @Lazy Badger said, you need to commit just that one file, then push that commit. – Waynn Lue Feb 26 '12 at 08:28
  • @WaynnLue - I tried the same thing. Just committed one file and i see that commit in separate section called 'Unsynced Commits', when try to click on Sync for that commit it throws error that please commit all your changes before syncing. So i believe its talking about the uncommitted changes. – Mutant Feb 26 '12 at 16:06
  • @Mutant If you want to successfully sync your changes while having uncommitted changes, you should follow the steps in the original answer. You'll have to stash any un-committed changes, do your sync, then unstash them. You'll either have to do this from the git command line (which you'll need to install), or you might be able to do it by switching branches (http://mac.github.com/help.html implies that switch branches automatically does stash for you). But you should try to do the first one, since it's probably the best way to do it. – Waynn Lue Feb 26 '12 at 21:37
  • I would say that you should only do this (stashing) if pushing (as suggested by @Curley) does not work. – Bart Nov 15 '13 at 09:01