What does "Git push non-fast-forward updates were rejected" mean?
A fast-forward update is where the only changes one one side are after the most recent commit on the other side, so there doesn't need to be any merging. This is saying that you need to merge your changes before you can push.
you might want to use force with push operation in this case
git push origin master --force
It means that there have been other commits pushed to the remote repository that differ from your commits. You can usually solve this with a
git pull
before you push
Ultimately, "fast-forward" means that the commits can be applied directly on top of the working tree without requiring a merge.
GitHub has a nice section called "Dealing with “non-fast-forward” errors"
This error can be a bit overwhelming at first, do not fear.
Simply put, git cannot make the change on the remote without losing commits, so it refuses the push.
Usually this is caused by another user pushing to the same branch. You can remedy this by fetching and merging the remote branch, or using pull to perform both at once.In other cases this error is a result of destructive changes made locally by using commands like
git commit --amend
orgit rebase
.
While you can override the remote by adding--force
to thepush
command, you should only do so if you are absolutely certain this is what you want to do.
Force-pushes can cause issues for other users that have fetched the remote branch, and is considered bad practice. When in doubt, don’t force-push.
Git cannot make changes on the remote like a fast-forward merge, which a Visual Git Reference illustrates like:
This is not exactly your case, but helps to see what "fast-forward" is (where the HEAD
of a branch is simply moved to a new more recent commit).
The "branch master->master (non-fast-forward) Already-up-to-date
" is usually for local branches which don't track their remote counter-part.
See for instance this SO question "git pull says up-to-date but git push rejects non-fast forward".
Or the two branches are connected, but in disagreement with their respective history:
See "Never-ending GIT story - what am I doing wrong here?"
This means that your subversion branch and your remote git master branch do not agree on something.
Some change was pushed/committed to one that is not in the other.
Fire upgitk --all
, and it should give you a clue as to what went wrong - look for "forks" in the history.