Shazam
Shazam

Reputation: 105

Cannot push to Git

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

Answers (3)

Ofir Lana
Ofir Lana

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

uncletall
uncletall

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

Hansika Wanniarachchi
Hansika Wanniarachchi

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

Related Questions