打赏
Fork me on GitHub

[原]git的使用(三)---管理修改、

上接git的使用(二)

7.管理修改

 [要理解的概念]为Git跟踪并管理的是修改,而非文件

  什么是修改?比如你新增了一行,这就是一个修改,删除了一行,也是一个修改,更改了某些字符,也是一个修改,删了一些又加了一些,

  也是一个修改,甚至创建  一个新文件,也算一个修改

  如下图:

-----------------------------------------------------------------------------------------------

  

-------------------------------------------------------------------------------------------------

[实践出真知]

  第一次修改readme.txt

$ vim readme.txt                                        #修改readme.txt 增加一行Git tracks changes.
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 add readme.txt                                    #提交到暂存区


$ git status                                            #查看工作区所有文件的状态
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   readme.txt

第二次修改readme.txt  未add提交到暂存区。

$ vim 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.

提交暂存区的代码到仓库

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

查看工作区的所有文件的状态

$ 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                                                    #第二次的修改没有被提交到仓库,因为未被add提交到暂存区,无法commit到仓库

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

 参考git教程:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

posted @ 2016-03-27 00:10  my_cool2007  阅读(237)  评论(0编辑  收藏  举报