As the output of the command git status tells you, If you want git to track a file, you must use the command git add to add it to the submit task. This command saves the files in the temporary storage area. All the files are waiting for submission, or they can be used in snapshots. The purpose of the Git add command is different when you include files in snapshots and add new or temporary files to be managed by git, but at least for now, you don't have to worry about the differences between them.
This is like opening a recorder and preparing a recording. As you can imagine, you can press the pause button on the recorder that is already in the recording, or roll back the start to record the next audio track.
Adding a file to a submitted task is not "prepare a recording ". This only places the file in the prepare recording state. After you add a file, you can still modify the file. It is only marked as tracked and in the temporary storage area, so you can remove or modify a tape before it is written to it (you can also add it again to make some modifications ). But please note: You have not recorded the file in the tape, so if you break a file that is still good, you cannot recover it, because you didn't remember the file in the tape, it's still a good time.
If you finally decide not to record the file to the Git history list, you can cancel the submission task. In Git, you do this:
This actually removes the recording preparation status of the recorder. You just made a transfer in the recording studio.
Large submissionSometimes you want to submit some content to the warehouse. In comparison to a recorder, it is like pressing the recording key and recording it into the tape.
In different stages of a project, you press the record key countless times. For example, if you try a new Python toolkit and finally implement the window rendering function, you must submit it, so that you can roll back to this stage when the new display options in the experiment are messed up. However, if you have drawn some sketch samples in Inkscape, you may have to wait until you have some content to develop before submitting. Although you may submit it many times, Git does not waste much or occupy too much disk space. Therefore, the more you submit, the better.
The commit command will "record" all the temporary storage area files in the repository. Git only records files that have been tracked, that is, all files that have been added to the temporary storage area by using the git add command at a certain point in the past, and files that have been changed since the last commit. If no submission was made before, all the tracked files will be included in this submission. From the Git perspective, this is a very important change because they have never been put into the repository and become put in.
To complete a submission, run the following command:
$gitcommit-m'Mygreatproject,firstcommit.'
This saves all submitted files and can then be used for other operations (or, in Gallifreyan, the Time Lord in the British TV series "Doctor of Mystery" said, they become "fixed time points "). This is not only a commit event, but also a reference pointer that you can find the commit in the Git log:
$ Gitlog -- oneline
55df4c2Mygreatproject, firstcommit.To view more information, you only need to use the git log command without the -- oneline option.
In this example, the reference number is 55df4c2. It is called "commit hash" (LCTT Note: This is a hash code generated by the SHA-1 algorithm, used to represent a git commit object ), it represents all the new changes you submitted just now, and covers the previous records. If you want to "flip back" to your submission history point, you can use this hash as the basis.
You can think of this hash as an SMPTE time code on a sound tape, or a bit more. This is like the gap between two different songs on a black rubber record, or the audio track number on a CD.
After you modify the files and add them to the submission task, the submission is completed. This generates a new hash for submission, each of their marked historical points represents different versions of your product.
That's why musicians like Charlie Brown use Git as a version control system.
In the next article, we will discuss various aspects of Git HEAD, and we will truly reveal the secrets of time travel to you. Don't worry, you just need to continue reading (maybe you are already reading ?).
From: http:// OS .51cto.com/art/201608/515601.htm
Address: http://www.linuxprobe.com/first-git-warehouse.html