O'Reilly logo

Professional Git by Brent Laster

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connected Lab 3

Tracking Content through the File Status Life Cycle

In this lab, you’ll work through some simple examples of updating files in a local environment and viewing the files’ status and differences between the various levels along the way.

Prerequisites

This lab assumes that you have done Connected Lab 2: Creating and Exploring a Git Repository and Managing Content. You should start out in the same directory as that lab.

Steps

  1. Starting in the same directory as you used for Connected Lab 2, run the status command or the short form to see how it looks when you have no changes to be staged or committed.
    $ git status
    $ git status –s
  2. Create a new file and view the status.
    $ echo content > file3.c
    $ git status
    $ git status –s

    Question:

    1. Is the file tracked or untracked?

    Answer:

    1. It’s untracked—you haven’t added the initial version to Git yet.
  3. Stage the file and check its status.
    $ git add .   (or git add file3.c)
    $ git status   (git status –s if you want)

    Questions:

    1. Is the file tracked or untracked?
    2. What does Changes to be committed mean?

    Answers:

    1. The file is now tracked—you’ve added the initial version to Git.
    2. Changes to be committed implies that files exist in the staging area and the next step for them is to be committed into the local repository.
  4. Edit the same file again in your working directory and check the status.
    $ echo change > file3.c
    $ git status

    Questions:

    1. Why do you see the file listed twice?
    2. Where is the version that’s listed as Changes to be committed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required