Getting Git -concept "stage"

It's still hard to find my head wrapped in the concept of staging, as it applies to Git.

Is it possible to draw an analogy with SVN? What is the main purpose of creating a scene level in Git?

+7
source share
3 answers

Similarities:

For tracking, you must add files that must be part of the repository. To do this, both tools use the add command. Adding files means preparing the commit.

Differences:

Git allows you to add additional files when adding files. You may decide to add the whole file or individual lines of code. Adding files to an index or step provides more flexibility. SVN automatically commits all changes to a file that has already been added to the repository. Git leaves a decision about what changes are associated with each transaction with the user. In other words: the next commit in Git contains only those changes (lines or files) that were delivered, regardless of the state of file tracking. SVN automatically includes all changes to tracked files.

Additional Information:

Try reading some posts describing Git workflows, such as one of the Oliver Steele . But keep in mind that there is more than one way to use Git - there are many. If you want, you can use Git as if you were working with SVN.
Don't expect an understanding of the Git philosophy in a short amount of time. It took me a year to get into it, and I'm still learning new ways to use it. I think this is even harder if you grew up with SVN thinking. There are lots of materials: articles, videos, ... - take your time and try some of them. Here is a selection from the list that I have compiled.

+7
source

The main advantage of the staging area is that you can easily commit only part of the changes to a given file. (For example, using git add -p .) As far as I know, the only way to make a β€œpartial” commit to SVN is at the level of each file, or manually back up the file and then temporarily revert the changes you hired. You don’t want to commit.

This is great if (like me) you are not a very organized developer and want to be able to sort the changes into "neat" commits after the fact. This follows Git's general attitude of preference, to give you the flexibility to provide rigor. If you don't need this, you can always just not use it and use git commit -a ...

There are no analogies with SVN, since SVN is not Git and does not have such a concept.

+6
source

Here are some of the scenarios that show the usefulness of staging:

  • You are working on a specific part and have made many changes to your project. You do not want to do them before testing the whole thing. But these changes can often be independent enough to make several logical errors than one big one. This is when you execute selective parts and make several commits.

  • The setting was especially useful for debugging. You can sprinkle log statements to track the source of the error. Then you perform the correction and try again using these log statements. But then you want to commit the fix before you make any changes to the code to remove these log statements.

  • Another scenario that turned out to be useful is when you are in the middle of something and find something unrelated, such as a typo that you want to fix, and quickly fix it.

There are several other similar scenarios, and you probably will not be able to work with anything that does not have this concept as soon as you hang it :).

PS: I did not use SVN at all, so I can not compare between them.

+4
source

All Articles