June 14, 2014 —John Koster
If you have been programming for some time, or have interest in keeping up with changes in the tech scene, then there is no doubt you have probably come across GitHub by now. If you are an adventurous programmer, you might even use it for your own projects or to contribute to various open source projects. GitHub is a commercial endeavor built around git
, and they do fairly well for themselves, and provide a great service.
If you are an experienced user of git, this post probably won't apply too much, but if you are just getting the hang of using git
for your version control, or need a nice GUI for your repositories, you might be using the GitHub for Windows (I might have forgotten to mention this post is about the Windows version of GitHub for Windows).
After working with GitHub for Windows for a while, it is possible you have come across this annoying message:
You cannot sync with uncommitted changes. Please commit your changes and try again.
There is an easy solution to this that doesn't include committing your half-done work. In the top-right corner of the window, you will see a gear. Clicking/tapping this gear will open a drop-down menu, and you will see an option called "Open in Git Shell". Selecting this option will open your repository in whatever command-line environment you have configured within the GitHub for Windows settings.
git push
Once the command-line environment opens, type the following command:
1git push
This will push all the changes you have committed to your repository, and you can get back to work! That's all there is to this method, thanks to the many readers (below) who have suggested this method - I'm always learning new things!
git stash
Again, once the command-line environment opens, type this command:
1git stash
After pressing enter, you should be able to return to the GitHub for Windows app and press the "Sync" button without any problems! This works because the git stash
command takes any files that are being tracked by git and just sets them off to the side for you. Once you stash something in git, as far as its concerned those changes are not part of working set. Of course, you probably want your changes back after you have synced your repository.
To get your changes back, return to the command line environment and enter this command:
1git stash pop
The git stash pop
command takes the changes you have previously stashed, or set off to the side, and puts them back into your working set.
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.