Still having a hard time getting my head wrapped around the concept of staging as it applies to Git.
Can any analogies be made with SVN? What is the primary purpose of having a stage level in Git?
Git has three main states that your files can reside in: modified, staged, and committed: Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
As the documentation says, git stage is just a synonym for git add , so there is no difference in usage.
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.
Similarities:
Files that should be part of the repository must be added in order to being tracked. Both tools use the add
command to accomplish this. Adding files means to prepare a commit.
Differences:
Git allows some further kind of detail when adding files. You can decide to add a whole file or distinct lines of code. Adding files to the index or stage allows more flexibility. SVN automatically commits all changes on a file that has already been added to the repository. Git leaves the decision of what changes to associate with each commit operation to the user. In other words: the next commit in Git only contains those changes (lines or files) that have been staged, regardless of the tracking status of the files. SVN automatically includes all changes on tracked files.
Additional information:
Try to read some posts describing Git workflows such as the one from Oliver Steele. But be aware that there is not one way to use Git - there are many. If you want, you can use Git as if you were working with SVN.
Do not expect to understand the philosophy of Git in a short period of time. It took me a year to get into it and I still learn new ways to use it. I think it is even harder if you grew up with SVN mindset. There are tons of materials out there: articles, videos, ... - take your time and try some of them. Here is a selection from the list I collected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With