Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I find git hard to understand as I could not find the meaning of the words used for the actions. I have checked the dictionary for the meaning of 'stage' and none of the meanings were related to source control concepts.

What does 'stage' mean in the context of git?

share|improve this question
up vote -6 down vote accepted

directly from Oxford (, at the bottom of page:

set the stage for: Prepare the conditions for (the occurrence or beginning of something).

In GIT terms, prepare the conditions for committing your files.

It worked for me, hope it work for you.

share|improve this answer
this doesn't seem to add anything substantial over prior 8 answers – gnat Aug 11 '14 at 19:29
Particularly sleske's answer, which uses the same source – Izkata Aug 12 '14 at 0:17
SO questions are intended to be answered by a knolowedged users, not copycats. What could you expect from a userxxxxxx based nick? XD – erm3nda Jul 5 at 0:45

To stage a file is simply to prepare it finely for a commit. Git, with its index allows you to commit only certain parts of the changes you've done since the last commit. Say you're working on two features - one is finished, and one still needs some work done. You'd like to make a commit and go home (5 o'clock, finally!) but wouldn't like to commit the parts of the second feature, which is not done yet. You stage the parts you know belong to the first feature, and commit. Now your commit is your project with the first feature done, while the second is still in work-in-progress in your working directory.

share|improve this answer
Good explanation. Note that git, being distributed, obviously allows you to commit both features, since commits are local (at first). Still, you might want to put split the modifications into one commit per feature, and again staging comes in handy. – sleske Nov 15 '11 at 9:08
I don't understand why you need staging for this. I can do this with HG or even SVN by only committing the relevant files. It feels like this feature is primarily designed to aid people who insist on working with the command line where it's harder to check boxes on what you are committing. – jiggy Sep 19 '12 at 17:55
@jiggy git allows you to stage part of a file. You can also stage a file, make further modifications, then commit the state it was in at staging. You can't do that in subversion. – Izkata Apr 30 '14 at 0:47
@Izkata even SVN allows committing only a part of a file now, or at least the TSVN client does. This has been true for at least 6 months at this point. – Vaibhav Garg Aug 8 '14 at 9:34
The second arrow "stage files" in the figure might be misleading. "stage hunks" might be more accurate? – Ida Oct 10 '14 at 13:44

Since everyone so far has answered it the "formal" way, let me do this with alternatives to enhance learning with the power of metaphors.

So the staging area is like:

  • a cache of files that you want to commit
  • not a series of tubes but actually a dump truck, ready to move the work you load it with, in to the repository
  • a magical place where selected files will be turned into stone with your wizardry and can be magically transported to the repository at your whim
  • the yellow brick road for the files to go happily to the repository (or fall off if you want to revert)
  • the fictional place at the sea port where files are received a pair of cement shoes and then thrown into the repository sea
  • the receptions desk at the library, you put the files there for the librarian to prepare for filing into the library
  • a box where you put things in before shoving it under your bed, where your bed is a repository of boxes you've previously have shoved in
  • the loading bay of files before it goes into the repository warehouse with the power loader
  • the filter of an electric drip coffee maker, if the files are like the coffee powder, then the committed files are the brewed coffee
  • the Scrooge McDuck's office next to the vault, the files are like the coins before they go into the vault of his massive Money Bin
  • the pet store, once you bring a pet home you're committed

It's magical!

share|improve this answer
If one of those doesn't stick I don't know what will. ;p – Steven Jeuris Nov 15 '11 at 8:09
+1 for the repository sea. – Bringer128 Nov 15 '11 at 8:26
Thanks for the great explanations, it helped me understood and memorize the concept. – Sam Nov 15 '11 at 14:17
+1 for Scrooge McDuck – Baggers Nov 4 '13 at 10:38
+1 for box under the bed – zencv Nov 7 '14 at 12:41

To stage a file is to prepare it for a commit. Because git exposes this action to the users control it allows you to create partial commits, or to modify a file, stage it, modify it again, and only commit or revert to the original modification.

Staging allows you finer control over exactly how you want to approach version control.

share|improve this answer
Good explanation. – MHZ Mar 20 '14 at 20:11

To add to the other excellent answers, here's where the name for "stage" comes from:

I checked the dictionary for the meaning of stage and none of the meanings was related to source control concepts.

In English, "to stage" can mean

organize and participate in (a public event): UDF supporters staged a demonstration in Sofia

(from )

The name "staging" for the git feature derives from this meaning: When staging, you are preparing and organizing a commit. Of course a commit is not quite the same as a performance, but it is an important event in a VCS :-).

share|improve this answer
I'd have thought it more closely matched the use in staging post – Useless Apr 30 '14 at 16:21
Ditto. Also, "a point, period, or step in a process or development." – Darien Aug 8 '14 at 23:05

Staging is a step before the commit process in git. That is, a commit in git is performed in two steps: staging and actual commit.

As long as a changeset is in the staging area, git allows you to edit it as you like (replace staged files with other versions of staged files, remove changes from staging, etc.).

Broken metaphor time:

Consider a scenario where you call the movers to get your stuff from your old appartment to your new appartment. Before you do that, you will go through your stuff, decide what you take with you and what you throw away, pack it in bags and leave it in the main hallway. The movers simply come, get the (already packed) bags from the hallway and transport them. In this example, everything until the movers get your stuff, is staging: you decide what goes where, how to pack it and so on (e.g. you may decide that half your stuff will be thrown away before the movers even get there - that's part of staging).

From a technical point of view, staging also supports transactional commits, by splitting all operations into what can fail (staging) and what cannot fail (commit):

The commit in git is implemented transactionally, after the staging is sucessfull. Several steps in the staging can fail (e.g. you need to commit, but your HDD is 99.9999% full, and git has no space to perform a commit). This will fail in staging (e.g. your repository will not be corrupted by a partial commit) and the staging process doesn't affect your commit history (i.e. it doesn't corrupt your repository in case of an error).

share|improve this answer
+1 surprised that such a simple analogy received no votes yet – zencv Nov 7 '14 at 12:43

With most other version control systems, there’s 2 places to store data: your working copy (the folders/files that you’re currently using) and the datastore (where the version control decides how to pack and store your changes). In Git there’s a third option: the staging area (or index). It’s basically a loading dock where you get to determine what changes get shipped away.


share|improve this answer
this doesn't seem to add anything substantial over prior 6 answers – gnat Jul 11 '14 at 4:13

The "stage" is a technically required intermediate step in the process of checking in a file, namely collecting the changes to be added to the repository. Git's authors chose to make this step visible and persistent where other VCS make it a transient part of the commit process. So it's just an option that git gives you because it can so why not?

The way I see it, the main thing the git "stage" gives you that other VCS don't is that you can use it to checkpoint a file. It's effectively an unnamed, uncommented local commit that gives you an intermediate step between being done with all your work and committing it to the repository permanently and having nothing saved in your local repo at all.

For example, let's say you have a feature partially finished. It's in a stable state, passes all the tests, and could go into production, but you have more work to do on it. You could stage all your changes and then continue to work on the feature.

Later, you'll have the option to just commit what you staged (and push that commit to the remote repository) or to add your new changes to your staging area and then commit that all at once, or to undo just your new changes and revert your working directory to the state it was in when you staged your changes.

It's completely possible to practically skip the staging area altogether and just use the -a option to git commit if you don't find the staging area a helpful concept. Lots of people skip staging and GUI tools usually allow for this, too.

share|improve this answer
"other VCS don't" -- what makes you think so? Shelving at Perforce appears to be doing what you describe, and even with few additional bells and whistles – gnat Apr 29 '14 at 20:39
@gnat yes, of course many other VCS give you something like staging. By "other VCS" I mean other VCS that don't have something like git's stage, since that is what the OP was referring to. – Old Pro Apr 29 '14 at 21:18

protected by gnat Aug 11 '14 at 19:29

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.