在git 中修改之前的提交内容

来源:互联网 发布:小额贷款app源码 编辑:程序博客网 时间:2024/05/21 03:26

备录下,省的又忘了。


比如要修改之前的commit的 hashcode为:187f869c9d54c9297d6b0b1b4ff47d2ec781a55e


Step 1:
先用git rebase 187f869c9d54c9297d6b0b1b4ff47d2ec781a55e^ --interactive //退回到要修改的commit的前一个点上,
执行后,git会调用默认的vi编辑器显示commit到最新commit的所有记录,把我们要修改的那一项的首行的pick 改成edit。

Step 2: 修改完我们要修改的内容后,利用git add 添加
 git add <filepattern>

Step 3: git commit --amend //修改这个commit

Step 4: git rebase --continue // 提交修改后的commit 并且返回到原来的head 处。


Fixing git: “interactive rebase already started”


If you’re like me, a fan of rebasing local work before publishing, maybe you receive this error:


"interactive rebase already started"


This happens when you abort in the middle of a rebase.


The way to fix it is using:


git rebase -i --abort


转自:http://blog.csdn.net/wangbole/article/details/8552808

0 0
原创粉丝点击