![]() ![]() 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. You could stage all your changes and then continue to work on the feature. It's in a stable state, passes all the tests, and could go into production, but you have more work to do on it. 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.įor example, let's say you have a feature partially finished. 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. So it's just an option that git gives you because it can so why not? Git's authors chose to make this step visible and persistent where other VCS make it a transient part of the commit process. 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. This will fail in staging (your repository will not be corrupted by a partial commit) and the staging process doesn't affect your commit history (it doesn't corrupt your repository in case of an error). Several steps in the staging can fail (for example, you need to commit, but your HDD is 99.9999% full, and git has no space to perform a commit). The commit in git is implemented transactionally, after the staging is sucessfull. you may decide that half your stuff will be thrown away before the movers even get there - that's part of staging).įrom a technical point of view, staging also supports transactional commits, by splitting all operations into what can fail (staging) and what cannot fail (commit): 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. The movers simply come, get the (already packed) bags from the hallway and transport them. 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. That is, a commit in git is performed in two steps: staging and actual commit.Īs 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.).Ĭonsider a scenario where you call the movers to get your stuff from your old appartment to your new appartment. Staging is a step before the commit process in git. the pet store, once you bring a pet home you're committed.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 filter of an electric drip coffee maker, if the files are like the coffee powder, then the committed files are the brewed coffee.the loading bay of files before it goes into the repository warehouse with the power loader. ![]() ![]() 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 receptions desk at the library, you put the files there for the librarian to prepare for filing into the library.the fictional place at the sea port where files are received a pair of cement shoes and then thrown into the repository sea.the yellow brick road for the files to go happily to the repository (or fall off if you want to revert).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.not a series of tubes but actually a dump truck, ready to move the work you load it with, in to the repository.a cache of files that you want to commit.Since everyone so far has answered it the "formal" way, let me do this with alternatives to enhance learning with the power of metaphors. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |