Skip to content

Instantly share code, notes, and snippets.

@rwarbelow rwarbelow/ Secret
Last active Jan 29, 2019

What would you like to do?
Why a staging area?

Let's say you are working on a large project with multiple pieces (the Mod 0 Curriculum site is a good example). When I was building out the content for Session 1 in a file called index.html, I had some ideas for Session 2 and Session 3. I added some jumbled and unitelligible notes in those files, but when it came time to publish Session 1, I didn't want to include the notes I had added to Session 2 and Session 3. So, I just added the Session 1 file and left the others alone. This is what my status would have looked like:

rwarbelow~/mod-0-curriculum$ git add session1/index.html
rwarbelow~/mod-0-curriculum$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

  modified:   session1/index.html

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  modified:   session2/index.html
  modified:   session3/index.html

The process of adding files to the staging area is a great way to sort out what you do and do not want to go into the commit.

To go back to the race analogy, the staging area is where the race officials can:

  1. gather all race participants
  2. make sure that all participants are ready to start
  3. ensure that spectators are not in the staging area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.