I made a commit & pushed to repo. Later I modified the commit message by using git commit --amend
, In the pop-up window I entered the new message. I could see the new message via git log
. After all this process, my git status
shows like this. I don't know how to push this change to repo.
On branch master
Your branch and `origin/master` have diverged,
and have 1 and 1 different commit(s) each, respectively.
Expecting a feasible solution for this.
Changing the latest Git commit message If the message to be changed is for the latest commit to the repository, then the following commands are to be executed: git commit --amend -m "New message" git push --force repository-name branch-name.
Amended commits are actually entirely new commits and the previous commit will no longer be on your current branch. This has the same consequences as resetting a public snapshot. Avoid amending a commit that other developers have based their work on.
If you are ok with modifying the history on the remote repo (as in, you just pushed that commit, and no new commits were made), you can try a
git push --force
However, do read first "How do I push amended commit to the remote git repo?": if anyone already pulled from that repo, he/she won't be happy.
An alternative is described in "Git: pushing amended commits".
As mentioned by cpeisert in the comment "master
branch and 'origin/master
' have diverged, how to 'undiverge' branches'?" described your warning message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With