How to Modify the Git Commit Messages After Your Push Your Branc
- 时间:2020-10-07 14:38:56
- 分类:网络文摘
- 阅读:132 次
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) —
推荐阅读:网络上流传甚广的垃圾食品方便面有毒、致癌的传闻是真的吗? 经常吃核桃仁可以补脑是真的吗 一天吃多少核桃才健康 甘蓝汁食疗方法对胃病患者非常有益 疗效甚至超过单纯药物 面部出现这些变化则是男人肾虚要进行饮食调理 酱油吃多了会导致皮肤变黑吗?别再被忽悠啦! 健康饮食:人们都说吃了“隔夜菜”致癌,这是真的吗? 豆腐味美又养生,做一道家常菜让你胃口大开 女性在特殊时期饮食需要注意,不能吃这些食物 此菜肴脆嫩爽口肉香浓郁且色香味俱全,为冬季百吃不厌的佳肴 枸杞子吃法正确才能更好吸收营养,但人在出现状况时最好别吃它
- 评论列表
-
- 添加评论