R
Shall we start by analyzing the names?staging area: area to electIn that part, you're riding a cast, but you haven't completed it yet. You are still calling the "actors" that will "participate the piece", the significant changes you want to put to posteritycommit: The closest I can translate comes in its substantive way: commitment, or commitmentIn that part, you are ready to seal a commitment to eternity. With everything that has been raised, you have put the important pieces at stake and are ready to make a commitment. Hence, commit I believe it can be translated as the reflective verb "compromises".There are other places to use commits, even if without clear translation. And one of the main ones is in database (I will get to the point where the git is a specific database, leave it hanging for a while). You can do all work in the database without making use of commits, which in turn is the final step of one transaction? Of course you can! But that offers risks.By the way, it has databases that do not offer other means of data updates that is not per transaction and closing in commit, as the /questions/tagged/sqlite . If you do not use this feature explicitly, it encompasses every DML operation that results in data changes within a begin transaction; ... seu update/insert/delete ... ; commit automatically.How does the transaction work in the database? Basically in it you call all actors, who are data manipulations and/or structure, and then happily closes a compromise or gives back and back everything rolling (roll back).In this sense, the transaction works as an area to elect changes and make a commitment.I quoted above that the git is a specific end database. It is not a relational database or NoSQL, it is a database based on changes in text segments (or binary, but it itself has been made to texts, binary is almost always marked as complete change). It simply stores the history of creating the documents and also the steps they have suffered to arrive in another state.In the case of git, the repository is understood as a single entity of knowledge, but may contain several documents. Sometimes a document change requires another to be so (for example, extracting a function from a source file by generalizing it in another source file). So it is natural that, for change to be atomic, it needs to actually occur in 2 or more corners at the same time. Without this warranty, you could have changes that would make the information that needs to be shared in several documents inconsistent.Well, then to group these changes there is commitment of you. Your commitment consists of a number of deltas (or document changes), your subscription (name/email) and a message to indicate with what you are committing. Yeah, right now, you married the code, congratulations. But know that there is no divorce, eternal commitment.If there was no area to elect, you could seal a commitment to a set of deltas whenever you feel the need. But there is no divorce... and if you were just getting ready? Well, in that case, you would assume a potentially wrong commitment. And we don't want to keep mistakes beyond eternity, do we?Here enters the area to elect. You are not yet ready to take on the commitment, but started to elect the important things. From extra features, you could use the stash to under the carpet changes that are not raised to see if they are atomic by themselves, or if it could have done differently. Also has the case https://pt.stackoverflow.com/a/320229/64969 , in which, after "sugar" your desktop, you do not seal a compromise, but two or more. I even often do as Marcel spoke and select the set of lines necessary for the desired change, without worrying about electing the entire file.Then, returning to the heart of the question: What is the utility of the area to elect? Is she really useless?It serves so that you can make commitments without future regrets (or almost that...). It also allows you ♪ gradually their commitment, their changes. Additionally, you can also use it to validate the changes you want to commit to.Yeah, I know. git commit --amend, but he looks more like a "post-nuptial pact", and he should not be too abused when his commitment became public, when you pushed to the remote the changes you think necessary.