Answer the question
In order to leave comments, you need to log in
Why is stage area needed in Git?
Why is it necessary to place files in the stage area before creating a commit? That is, it is clear that new files need to be added using add, but why add files that are already under control? Why was such a concept adopted? After all, in fact, it turns out that the stage area is a repository within a repository. First we add files to the stage, then we commit them all to the local repository, then we push to the remote repository. Why this extra step in the form of a stage?
Answer the question
In order to leave comments, you need to log in
I think the answer is a little banal - so that you can choose which files to include in the commit.
From practice - most often it happens git commit -am "...", it has already reached automaticity. Those. I look at the status, if there are new ones, I add them, and then commit with the -a flag. But I have it. Because in my case, git is mostly needed for team work - I don’t really use version control myself. If you need to balance between versions, brunches are used.
However, if you really treat every commit as if it were a stable release for production, then this approach may be necessary. In this case, just the same staging area plays the role of a draft, from which you can include certain files.
Again, from practice - sometimes it is convenient to commit a certain file in the case of hotfixes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question