修改已经提交的commit的message

本文介绍了一种简单的方法来修改已提交到Git中的错误提交信息。通过使用`git rebase -i`命令并选择要修改的提交,可以将提交信息更改为正确的版本。完成修改后,使用`git push --force`更新远程仓库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

不小心写错committing message并且已经提交怎么修改呢?

Easiest solution (but please read this whole answer before doing this):

  1. git rebase -i <hash-of-commit-preceding-the-incorrect-one>(这里可以用要改的那次的hash,如果是前一两次也可以用HEAD^或者HEAD^^)(这里的hash code必须是要修改的的那次提交的前一次commit的hash code)
  2. In the editor that opens, change pick to reword on the line for the incorrect commit.
  3. Save the file and close the editor.
  4. The editor will open again with the incorrect commit message. Fix it.
  5. Save the file and close the editor.
  6. git push --force to update GitHub.
转过来以防忘记
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值