How to Modify the Git Commit Messages After Your Push Your Branc

  • 时间:2020-10-07 14:38:56
  • 分类:网络文摘
  • 阅读:111 次

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)

git-commit-amend-message How to Modify the Git Commit Messages After Your Push Your Branch? git tutorial

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 How to Modify the Git Commit Messages After Your Push Your Branch? git tutorial

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) —

推荐阅读:
免插件为wordpress配置SMTP服务  如何解决wordpress密码设置链接失效的问题  为 wordpress 后台添加“全部设置”选项  如何自定义wordpress默认的图片附件链接方式  关于 wordpress 古腾堡编辑器易出现的两个错误信息  如何在wordpress首页侧边栏小工具中添加和使用短代码  wordpress 5.4 通过区块产出更多内容,又快又简单  如何让wordpress在全国哀悼日变成黑白/灰色调  通过自定义HTML小工具为wordpress添加倒计时模块  将一个正方形纸片剪去一个宽4cm的长条 
评论列表
添加评论