git study notes --- management modifications

Now, assuming that you have mastered the concept of the staging area. Below, we discuss is why Git designed to be better than the other version control system, track and manage because Git is to modify, rather than files.

You may ask, what is a modification? For example, you add a line, which is a modified, deleted a row, is a modified, changed some characters, is a modified, deleted some and added some, is a modified, or even create a new file, are also considered a modification.

Why Git is to modify the management, not the file it? We still do experiments. The first step, to make a readme.txt modification, such as adding a single line:

$ cat readme.txt
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.

 

Then, add:

$ git add readme.txt
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   readme.txt
#

  

Then, modify readme.txt:

$ cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes of files.

  

submit:

$ git commit -m "git tracks changes"
[master 519219b] git tracks changes
 1 file changed, 1 insertion(+)

 After submitting, then look at the status:

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   readme.txt

no changes added to commit (use "git add" and/or "git commit -a")

  

Hey, how's the second modification has not been submitted?

Do not get excited, we review the operation:

First Revision ->  git add -> The Second Amendment -> git commit

You see, we've talked about, Git management is modified when you use git addthe command, in the first modification of the workspace is placed in the staging area, ready to submit, however, in the second revision of the work area and not put in storage area, so the git commitonly responsible to modify staging area submitted, which is the first modification is submitted, a second modification will not be submitted.

Once submitted, with the git diff HEAD -- readme.txtcommand to see the difference between the workspace and the repository inside the latest version:

$ git diff HEAD -- readme.txt 
diff --git a/readme.txt b/readme.txt
index 76d770f..a9c5755 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,4 +1,4 @@
 Git is a distributed version control system.
 Git is free software distributed under the GPL.
 Git has a mutable index called stage.
-Git tracks changes.
+Git tracks changes of files.

  Visible, The Second Amendment did not commit.

How that submitted a second amended? You can continue git addagain git commit, you can not worry submitted to the first modification to git addthe second modification, then git commit, is equivalent to submit a revised twice after the merger:

First Revision ->  git add -> The Second Amendment ->  git add -> git commit

Well, now, the second revision submitted, and then start summary.

summary

Now, you have to understand how Git track changes, each modified, if not git addto the staging area, it will not be added to the commitmedium.

 

Guess you like

Origin www.cnblogs.com/saryli/p/11367861.html