记录修改历史git log 中的某个commit

commit e0eb5b86e0661abdb88b5327caa479861a1d1714 (HEAD)
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Tue Jan 12 08:38:02 2021 -0500

    add e.txt
    add new to e
    add new to c

commit 8030327c7250f75eef8037cfd93d61904bde4509
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Tue Jan 12 08:37:42 2021 -0500

    add d.txt

commit 43b4d9399ef13eb8200575c2d24c249a1ac07070
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Sun Jan 10 09:50:37 2021 -0500

    c.txt add more file to 3.txt
    add my c.new file

commit 9e1c44ed2592ccc0a1d5d5efb0bcd80e36a738cd
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Sun Jan 10 09:50:11 2021 -0500

    add a.txt file 1st

上面这是修改之前的 git log
我想修改 43b4d9399ef13eb8200575c2d24c249a1ac07070 这个commit 中的内容

#git rebase 9e1c44ed2592ccc0a1d5d5efb0bcd80e36a738cd --interactive 

Stopped at 43b4d93...  c.txt add more file to 3.txt add my c.new file
You can amend the commit now, with

  git commit --amend 

Once you are satisfied with your changes, run

  git rebase --continue


之后修改你要改的code

#git commit --amend 

[detached HEAD aa5ad9c] c.txt add more file to 3.txt add my c.new file
 Date: Sun Jan 10 09:50:37 2021 -0500
 4 files changed, 7 insertions(+)
 create mode 100644 add_new_file.txt
 create mode 100644 b.txt
 create mode 100644 c.new.txt
 create mode 100644 c.txt

再rebase 到原来的分支.

#git rebase --continue 
commit 4bd46b85049cf10cf6a3769c20b3074c2928a710 (HEAD)
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Tue Jan 12 08:38:02 2021 -0500

    add e.txt
    add new to e
    add new to c

commit 3898c0a8f7fb68d1d62cd2eab95d508521f3b99f
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Tue Jan 12 08:37:42 2021 -0500

    add d.txt

commit aa5ad9cff6735dda992c59eeb4faabd16c88377b
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Sun Jan 10 09:50:37 2021 -0500

    c.txt add more file to 3.txt
    add my c.new file
    
    2. add new file ccc.new

commit 9e1c44ed2592ccc0a1d5d5efb0bcd80e36a738cd
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Sun Jan 10 09:50:11 2021 -0500

    add a.txt file 1st

上面这是修改后的git log, 可以看到我已经修改了一部分内容到这个commit

commit aa5ad9cff6735dda992c59eeb4faabd16c88377b
Author: Perry Yuan <perry_yuan@dell.com>
Date:   Sun Jan 10 09:50:37 2021 -0500

    c.txt add more file to 3.txt
    add my c.new file
    
    2. add new file ccc.new

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值