The Mechanics of Commits
You can add a new file to your repo doing:
git add <mynewfile>
git status (this will show any pending commits)
git commit -m "a little comment, if you please" <mynewfile>
git status (this will show any pending commits)
git commit -m "a little comment, if you please" <mynewfile>
Once you commit, you should get a message like:
[master (root-commit) strange_hexadecimal_code] comment from -m command line flag
"1 file changed, X insertions(+)"
create mode 100644 filename.xx
If you didn't do a git add, it will say "nothing to commit, working tree clean".
The 100644 is Unix style permissions - 100 means regular file, 644 means read/write for owner and read-only for group and others.
Committing to Git is a Two-Step Process
Stating the obvious here, but as stated above, you need to git add before you git commit for new files.
The Semantics of Commits
When we commit, Git invokes an algorithm to create a "commit object", a binary object which it stores inside the .git folder. A unique identifier is used to "stamp" the commit. Part of the "stamp" is shown in the git commit response message - and is computed from a bunch of metadata including the commiter's name, time of commit, commit message and information on the change.
The Index and the Object Database
When you do a git add, a copy is made of the file and put into the index. The index is like a "waiting room" where we put in our "candidate" objects until we are ready to commit them. git commit takes the objects in the waiting room and puts them into the object database.
No comments:
Post a Comment