git commit --amend 改写提交

1. commit --amend

为了节省时间,这个教程使用现有的历史记录作为本地数据库。

从这里下载

我们将修改最近一次的提交。

首先进入stepup-tutorial/tutorial1目录。本地端的历史记录状态如下图显示。

数据库的历史记录

用log命令确认历史记录。

$ git log
commit 326fc9f70d022afdd31b0072dbbae003783d77ed
Author: yourname <yourname@yourmail.com>
Date:   Mon Jul 16 23:17:56 2012 +0900

    添加add的说明

commit 48eec1ddf73a7fb508ef664efd6b3d873631742f
Author: yourname <yourname@yourmail.com>
Date:   Mon Jul 16 23:16:14 2012 +0900

    first commit

首先打开sample.txt档案,并添加commit的注释。

连猴子都懂的Git命令
add 把变更录入到索引中
commit 记录索引的状态

添加 --amend 选项,然后提交。

$ git add sample.txt
$ git commit --amend

编辑工具会显示最近一次提交的提交消息,把消息修改为「添加add和commit的讲解」并进行保存。

现在已经修改了提交的内容,然后用log命令确认历史记录和提交消息。

commit --amend

$ git log
commit e9d75a02e62814541ee0410d9c1d1bf47ab1c057
Author: yourname <yourname@yourmail.com>
Date:   Mon Jul 16 23:17:56 2012 +0900

    添加add和commit的讲解

commit 48eec1ddf73a7fb508ef664efd6b3d873631742f
Author: yourname <yourname@yourmail.com>
Date:   Mon Jul 16 23:16:14 2012 +0900

    first commit
from: http://backlogtool.com/git-guide/cn/stepup/stepup7_1.html
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值