Error: Cannot pull with rebase: You have unstaged changes

user3597950 picture user3597950 · May 7, 2014 · Viewed 226.8k times · Source

I have started collaborating with a few friends on a project & they use the heroku git repository.

I cloned the repository a few days ago and they have since made some changes so I am trying to get the latest updates

I ran the git pull --rebase command as stated here(Is this the right way to do it?): https://devcenter.heroku.com/articles/sharing#merging-code-changes

I get the following error:

$ git pull --rebase
Cannot pull with rebase: You have unstaged changes.
Please commit or stash them.

My guess is that I messed around with the code and now it wants me to either commit or discard(is that what does stash means?) the changes. Is this what is happening? If this is the case I would like to discard any changes I might have made and just get the updated code from the git repository.

Any idea of what I can do?

Answer

Schleis picture Schleis · May 7, 2014

Do git status, this will show you what files have changed. Since you stated that you don't want to keep the changes you can do git checkout -- <file name> or git reset --hard to get rid of the changes.

For the most part, git will tell you what to do about changes. For example, your error message said to git stash your changes. This would be if you wanted to keep them. After pulling, you would then do git stash pop and your changes would be reapplied.

git status also has how to get rid of changes depending on if the file is staged for commit or not.