0

Possible duplicate, but I hit the following issue when using those answers.

Situation:

I didn't set up my github locally when I pushed a commit so the author information is incorrect. I've now set the global user.name and email correctly. But I would like to update that commit with the new information.

Attempt: Starting from the origin

git checkout my_branch 

git pull 

git commit --amend --author="My Name <me@example.com>" --no-edit

git push 

triggers the following error:

 ! [rejected]            mybranch -> mybranch (non-fast-forward)
error: failed to push some refs to 'https://github.com/xyz'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

What is the correct way to pass the update to the live repo?

F.D
  • 767
  • 2
  • 10
  • 23
  • You need to *force* push to replace the existing history, but be careful about doing this on repos other people are also trying to work on. – jonrsharpe Feb 02 '21 at 12:12
  • do only force push if no one else is working on the same branch! otherwise you might overwrite changes of other users – caramba Feb 02 '21 at 12:13
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+tip+of+your+current+branch+is+behind – phd Feb 02 '21 at 12:44

1 Answers1

0

I think, you have already pushed previous commit into your remote git repository(github). If so, then you can use push force command to rewrite the previous commit author.

git push --force