集册 沉浸式学 Git 修正提交

修正提交

欢马劈雪     最近更新时间:2020-08-04 05:37:59

89

目的

学习如何修正现有的提交。

更改程序并提交

给程序添加作者注释。

# Default is World
# Author: Jim Weirich
name = ARGV.first || "World"

puts "Hello, #{name}!"
$ git add hello.rb
$ git commit -m "Add an author comment"

唉,该有 Email 啊

在你做了提交之后,你意识到任何好的作者注释都应该包含 Email 地址。更新 hello 程序来包含 Email。

# Default is World
# Author: Jim Weirich (jim@somewhere.com)
name = ARGV.first || "World"

puts "Hello, #{name}!"

修正先前的提交

我们真的不想因为 Email 而分开提交。让我们修正先前的提交来包含 Email 更改。

$ git add hello.rb
$ git commit --amend -m "Add an author/email comment"
$ git add hello.rb
$ git commit --amend -m "Add an author/email comment"
[master eb30103] Add an author/email comment
 1 files changed, 2 insertions(+), 1 deletions(-)

回顾历史

$ git hist
展开阅读全文