Reputation: 105
I cannot commit and push to Git.
It says: Rejected - non - fast forward.
I have accidentally click on "Amend - (edit previous commit) button in Eclipse.
What can I do?
Please help. Thanks.
Upvotes: 0
Views: 812
Reputation: 393
You must grab the latest change from the remote before you can push yours.
try this pull without rebase first and see if it's working
git pull origin master
In case it doesn't work pull again with --rebase
git pull --rebase origin master
After that create a new commit
git commit --COMMIT
Then do a push
git push origin master
Upvotes: 1
Reputation: 6842
The simplest way to resolve this is by rebasing your change on the origin/master. This should create a new changeset that will only contain the difference that you made.
git rebase origin/master
git commit --amend -m"Update your commit message for the new commit"
git push origin HEAD:master
Upvotes: 1
Reputation: 137
You can solve this issue with a
git pull before you push
Actually this issue shows that there have been any other different commits pushed to the remote repository, fast-forward
means that the commits can be applied directly on top of the working tree without requiring a merge.
Upvotes: 1