How to merge remote changes at GitHub?
I'm getting following error, whn trying first Github push:
开发者_StackOverflow社区[rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:me/me.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'non-fast forward'
section of 'git push --help' for details.
how can I fix this and merge remote changes?
See the 'non-fast forward' section of 'git push --help' for details.
You can perform "git pull", resolve potential conflicts, and "git push" the result. A "git pull" will create a merge commit C between commits A and B.
Alternatively, you can rebase your change between X and B on top of A, with "git pull --rebase", and push the result back. The rebase will create a new commit D that builds the change between X and B on top of A.
You can also force a push by adding the + symbol before your branch name.
git push origin +some_branch
You probably have changes on github that you never merged. Try git pull
to fetch and merge the changes, then you should be able to push. Sorry if I misunderstood your question.
If you "git pull" and it says "Already up-to-date.", and still get this error, it might be because one of your other branches isn't up to date. Try switching to another branch and making sure that one is also up-to-date before trying to "git push" again:
Switch to branch "foo" and update it:
$ git checkout foo
$ git pull
You can see the branches you've got by issuing command:
$ git branch
You can force it to push, but please do this ONLY when you're quite sure what you are doing.
The command is:
git push -f
This problem can also occur when you have conflicting tags. If your local version and remote version use same tag name for different commits, you can end up here.
You can solve it my deleting the local tag:
$ git tag --delete foo_tag
When I got this error, I backed up my entire project folder. Then I did something like
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master
...depending on your branch name (if it's not master).
Then I did git pull --rebase
. After that, I replaced the pulled files with my backed-up project's files. Now I am ready to commit my changes again and push.
精彩评论