[cctbxbb] Git

Luc Bourhis luc_j_bourhis at mac.com
Tue Jan 12 12:45:46 PST 2016


> We discussed your "git add -p" suggestion in our group meeting just now, and nobody here could explain why the command would be "git add" rather than "git commit".  So if you want to commit all of your changes at once you would use "git commit", but not "git add"?  Or is "git add" mandatory anytime you want to commit any change and it is only the "-p" flag that is optional?

git has the concept of the staging area which svn does not have:

- git add some_file.py will add the whole file to the staging area
- git add -p will let you select which chunks go into the staging area

and you can mix and match those with different files at your heart content. When the staging area contains what you want in your commit, then you just do

git commit -m ‘your commit message’

and everything in the staging area will end up in that new commit.

But sometimes, you just want to commit a single file and then you can do the shortcut:

git commit -m ‘message’ your_file.py

which is equivalent to

git add your_file.py

followed by

git commit -m ‘message’

I hope this answers your question.

Luc




More information about the cctbxbb mailing list