Undoing Local Changes
Make sure you are on the latest commit in master before proceeding.
Change hello.rb to have a bad comment.
hello.rb
name = ARGV.first || "World"
puts "Hello, #{name}!"
Output:
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
modified: hello.rb
no changes added to commit (use "git add" and/or "git commit -a")
We see that the hello.rb
file has been modified, but hasn’t been staged yet.
Output:
Updated 1 path from the index
$ git status
On branch master
nothing to commit, working tree clean
$ cat hello.rb
# Default is "World"
name = ARGV.first || "World"
puts "Hello, #{name}!"
The status command shows us that there are no outstanding changes in the working directory. And the “bad comment” is no longer part of the file contents.