Posted by & filed under Web Development.

These errors when going a “git pull” can be very confusing. They indicate that there are local changes that would otherwise be obliterated, and you are prevented from continuing unless you commit your changes, move or delete the file before doing a pull, or the following workaround…

These errors when going a “git pull” can be very confusing. They indicate that there are local changes that would otherwise be obliterated, and you are prevented from continuing unless you commit your changes, move or delete the file before doing a pull, or the following workaround. There are probably several other alternative solutions too.

Sometimes these sorts of errors can come up when you, say, replace a physical file with a symbolic link. Other times you know you don’t care about your local changes and you just want to sync up with your remote site no matter what. To force a pull you can do the following:

git stash
git pull

git stash will “stash” away your local changes to a temporary directory. After running the above commands you can “git stash pop” to try to merge in your changes from your stash to your working tree, or “git stash clear” to delete your stash. “git stash list” will list all of your stashes.

It is suggested that you play around with this with a copy of your data to get a hang of this. The nice thing about git compared to Subversion (for those of you contemplating the switch) is that it is trivial to create copies of your project with a single file copy command.