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 adventerous 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 commiting 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.
Once the command-line environment opens, type the following command:
This will push all the changes you have committed to your repository, and you can get back to work! Thats all there is to this method, thanks to the many readers (below) who have suggested this method - I'm always learning new things!
Again, once the command-line environment opens, type this command:
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:
git stash pop
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.
There you go! Now you know how to get around the annoying pop-up message that might plague you for a while while using GitHub for Windows! If you found this post helpful, share it around with your friends, leave a comment, or just sit there awkwardly. It's really up to you.