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

    1. name = ARGV.first || "World"
    2. puts "Hello, #{name}!"

    Output:

    1. $ git status
    2. On branch master
    3. Changes not staged for commit:
    4. (use "git add <file>..." to update what will be committed)
    5. modified: hello.rb
    6. 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:

    1. Updated 1 path from the index
    2. $ git status
    3. On branch master
    4. nothing to commit, working tree clean
    5. $ cat hello.rb
    6. # Default is "World"
    7. name = ARGV.first || "World"
    8. 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.