在处理之前确认你在 master 中的最新提交上。
更改 hello.rb 让其具有错误的注释。
# This is a bad comment. We want to revert it.
name = ARGV.first || "World"
puts "Hello, #{name}!"
# On branch master
# Changes not staged for commit:
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: hello.rb
#
no changes added to commit (use "git add" and/or "git commit -a")
我们看到 hello.rb 已被修改,但还没有暂存。
# On branch master
nothing to commit (working directory clean)
$ cat hello.rb
# Default is "World"
name = ARGV.first || "World"
puts "Hello, #{name}!"
命令显示在工作目录中没有未完成的更改。而且“错 误的注释”也不再成为文件内容的一部分。