Git修改历史的某次提交

当Git提交不满意时,可通过`git rebase -i HEAD~3`列出最近三次提交,并将要修改的提交改为`edit`。在`no-branch`状态下修正提交,用`git commit --amend`覆盖,最后使用`git rebase --continue`完成修改。这是一个方便的Git历史修改技巧。
摘要由CSDN通过智能技术生成

Git使用中,如果遇到某一次的提交不满意,可以使用如下方法修改


# git rebase -i HEAD~3  >>> HEAD~3表示列出最近三次的

之后会出现

  1 pick 6e1bb94 modify
  2 pick 1769e78 delete
  3 pick 7ce9cad delete
  4
  5 # Rebase 491ed3f..7ce9cad onto 491ed3f
  6 #
  7 # Commands:
  8 #  p, pick = use commit
  9 #  r, reword = use commit, but edit the commit message
 10 #  e, edit = use commit, but stop for amending
 11 #  s, squash = use commit, but meld into previous commit
 12 #  f, fixup = like "squash", but discard this commit's log message
 13 #  x, exec = run command (the rest of the line) using shell
 14 #
 15 # These lines can be re-ordered; they are executed from top to bottom.
 16 #
 17 # If you remove a line here THAT COMMIT WILL BE LOST.
 18 # However, if you remove
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值