How to Modify the Git Commit Messages After Your Push Your Branc
- 时间:2020-10-07 14:38:56
- 分类:网络文摘
- 阅读:117 次
Git is a popular and widely used version control system. If you stage your local changes and commit it to local branch, you can change the commit message by:
1 | git commit --amend "new message" |
git commit --amend "new message"
If you simply type without the message parameter:
1 | git commit --amend |
git commit --amend
Git will launch a text editor for you to change the commit message. You can edit and then save and exit (usually :wq for vim)

This command only allows you to amend the last commit – if you want to change multiple commit message you can git rebase
For example, you can change the last two commits:
1 | git rebase -i HEAD~2 |
git rebase -i HEAD~2

git-rebase-i-commit-message
Then, you can reword, drop, or squash commit messages. You can also exec to run external command for example if you want to reword to a multiline commit message.
Once you have done changing the commit messages, you can git push -f to remote branch.
If you have a messy branch, it is recommended that you git checkout -b NewBranch then git merge MessyBranch, then you can squash your commit message by git commit -m “Squashed new commit message”.
–EOF (The Ultimate Computing & Technology Blog) —
推荐阅读:全国人大常委会关于修改《中华人民共和国高等教育法》的决定(主席令第四十号) 中华人民共和国反家庭暴力法(主席令第三十七号) 全国人大常委会关于修改《中华人民共和国教育法》的决定(主席令第三十九号) 中华人民共和国国家勋章和国家荣誉称号法(主席令第三十八号) 中华人民共和国反恐怖主义法(主席令第三十六号) 地图管理条例(国务院令第664号) 中华人民共和国宪法 全国社会保障基金条例(国务院令第667号) 2016年国务院关于修改部分行政法规的决定 居住证暂行条例(国务院令第663号)
- 评论列表
-
- 添加评论