Git may have more than 100 commands. There are not many commands, but each command can take many parameters, which is very powerful. Git commands always fall into two categories: high-level commands and low-level commands.
Gita Add and git commit are both high-level commands, and high-level commands complete operations by calling multiple low-level commands. In this section, I hope you can thoroughly understand git add and git commit.
For example, if we build a new project and create a new test.go file, and write something in the file at will, let's use the underlying commands to generate a complete git history:
Step 1: Generate a binary storage object for the test.go file.
Git hash-object command is to generate its binary storage object for a file and return its sha 1 signature code. Suppose it returns "0d5a2b6190403EF081242860845106558.
Step 2: Update the index file
This step is to add the object generated in the previous step and its path to the index. We use the updae-index command discussed in the previous section.
The above two commands are completely equivalent to the git add test.go command.
Step 3: Generate the directory tree object.
After calling the write-tree command, git will generate a tree object according to the directory structure of the current index area, and return the sha 1 signature code of this tree object, assuming that it returns: d8329f.
Step 4: Generate the submission object.
The content in single quotation marks after echo is our submission message. The third and fourth steps are to complete the git submit command operation.
You can try to operate the above four commands, and in the. Git/objects directories and workspaces.