Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git telling me to pull, then commit, then pull?

Tags:

git

github

I am trying to push new changes, but I have a conflicted file. After trying to push, I get the following error:

Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

Ok, so we need to use git pull. I try to use git pull and then I get this error:

error: Your local changes to the following files would be overwritten by merge:
    db/profile_edit.php
Please, commit your changes or stash them before you can merge.

But, when I try to commit, I go back to the first error. What should I do? The changes on the remote repo are newer than the ones on my local machine. So, how do I open it up with a diff tool and make the changes and then tell git that I have made changes so it will let me push changes?

like image 484
egidra Avatar asked Jul 20 '11 23:07

egidra


1 Answers

Try to do

$ git pull --rebase

To pull remote changes before yours, and then commit. And see if it works.

If this does not work, try this instead:

$ git stash
$ git pull --rebase
$ git stash pop

To save your changes on the stash, apply remote commits inside your work-repository, and then apply your changes (saved into stash) inside your work-repository again.

like image 152
Gabriel L. Oliveira Avatar answered Sep 28 '22 05:09

Gabriel L. Oliveira