amend

How do I push amended commit to the remote Git repository?

我与影子孤独终老i 提交于 2019-11-25 23:59:53
问题 When I\'ve worked a bit with my source code, I did my usual thing commit and then I pushed to a remote repository. But then I noticed I forgot to organize my imports in the source code. So I do the amend command to replace the previous commit: > git commit --amend Unfortunately the commit can\'t be pushed back to the repository. It is rejected like this: > git push origin To //my.remote.repo.com/stuff.git/ ! [rejected] master -> master (non-fast forward) error: failed to push some refs to \'/

How to modify existing, unpushed commit messages?

感情迁移 提交于 2019-11-25 23:57:16
问题 This post is a Community Wiki . Edit existing answers to improve this post. It is not currently accepting new answers. I wrote the wrong thing in a commit message. How can I change the message? The commit has not been pushed yet. 回答1: Amending the most recent commit message git commit --amend will open your editor, allowing you to change the commit message of the most recent commit. Additionally, you can set the commit message directly in the command line with: git commit --amend -m "New