Wednesday, September 7, 2011

Stashing Local Changes to a Git Repository When Pulling from Remote Repo

You can update your local repository with the remote by using the command:

$ git pull origin "remote_name"

If you receive an error like this:

error: Your local changes to 'projectFolder/fileName' would be overwritten by merge. Aborting. Please, commit your changes or stash them before you can merge.

You can ‘stash’ your local changes and revert them later by using the command:

$ git stash save "comment goes here - describe reason Local copy diffs from repo?"

Then you can do the pull without any errors.

$ git pull origin "remote_name"

To restore the stash from earlier use the command:

$ git stash pop

Hope this is helpful to those using git for deployment.

No comments:

Post a Comment