Git,比较暂存区域和工作副本

我们创造了一个文件,名叫Tuna,金枪鱼。然后在里面有几个文件,如图:

Git,比较暂存区域和工作副本

现在,我们打开第一个first.txt文件,里面内容如下:

 

Git,比较暂存区域和工作副本

 现在,我们来修改这个文件里面的内容,修改如下:

 

Git,比较暂存区域和工作副本

 好了,我们用git工具来看一下,现在我们进入这个文件夹:

Git,比较暂存区域和工作副本

 我们输入命令:git status:

Git,比较暂存区域和工作副本

 So now we try to type in:git add first.txt:

Notice before that:this file we are operating now is named "first" with ".txt" as its extension name.

So this is what happened next:

Nothing happened.We can't see anything happening simply from the screen,but something is happening somewhere we can't see or feel.

Now we try to type in:git diff:

Git,比较暂存区域和工作副本

 Why?because that the instruction "git diff" simply compares your repository against your woking copy,but the instruction "git add blablabla" simply adds the changes made to the file to the staging area.That's why nothing happens when you type in just that.

Of course this is not good for us to use.We surely want to compare more than this.So,you add a little bit more to the tail of that instruction and everything will be solved.What is it that we should add to the tail of the original instruction?Simple."git diff --staged" will work this time.

Like this:

Git,比较暂存区域和工作副本

 See what happens?Sometimes you could miss the "minus minus" just like what I did,which is absolutely fatal.So you should never miss it.

Okay,we are good now,because we are comparing the staging area and our working copy now.

That should do it.

Oh,don't forget the final instruction "git commit -m 'blablabla'" to complete the process:

Git,比较暂存区域和工作副本

 

 

 

 

 

 

 

上一篇:ES7 中对索引指定副本和分片数


下一篇:es6迁移到es7