0

I've performed the following steps in git:

git stash git pull origin develop git stash apply git commit -a -m 'da de da' git push origin develop <correct local date> GIT_COMMITTER_DATE="`date`" git commit --amend --date "`date`" git pull origin develop git push origin develop 

All the pushes gave this error:

 ! [rejected] develop -> develop (non-fast-forward) error: failed to push some refs to '<details>:/var/git/mygagenet' To prevent you from losing history, non-fast-forward updates were rejected 

How do I correct this problem?

1 Answer 1

1

This part of the error message:

To prevent you from losing history, non-fast-forward updates were rejected

tells you why the push was rejected - it doesn't just add new commits on top of the existing ones (which Git calls a "fast-forward update"), but it changes commits you've already pushed. In this case, the git commit --amend on your most recent commit has changed that commit.

You can force the push to happen by using

git push --force origin develop 

But if this is a remote branch that other people are using, check with them before you use git push --force on the branch, as they may have already done work on this branch with the existing commits.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but I realised I'm being an idiot. I forgot to check I'm on the correct branch :(. Will close the question.
No worries, glad you found the solution you needed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.