首页 > 其他 > 详细

git的使用(三)

时间:2016-03-27 01:37:46      阅读:108      评论:0      收藏:0      [点我收藏+]

上接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.cnblogs.com/horizonli/p/5324606.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!