Git管理修改

来源:互联网 发布:个人淘宝账号永久封号 编辑:程序博客网 时间:2024/05/29 19:08
1. 修改readme.txt
git is a version control system.git is free software under the GPL.git tracks changes.

2. 添加到暂存区
$ git add readme.txt$ git statusOn branch masterChanges to be committed:  (use "git reset HEAD <file>..." to unstage)        modified:   readme.txt

3. 修改readme.txt
git is a version control system.git is free software under the GPL.git tracks changes of files.

4. 提交至版本库
$ git commit -m "tracks change"[master 1161148] tracks change 1 file changed, 2 insertions(+), 1 deletion(-)

5. 查看状态
$ git statusOn branch masterChanges 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.txtno changes added to commit (use "git add" and/or "git commit -a")
发现第二次的修改并没有被提交,
操作过程: 第一次修改 -> git add -> 第二次修改 -> git commit
Git管理的是修改,用git add命令后,在工作区的第一次修改被放入暂存区,准备提交,但是,在工作区的第二次修改并没有放入暂存区,所以,git commit只负责把暂存区的修改提交了,也就是第一次的修改被提交了,第二次的修改不会被提交。/

6. 查看工作区和版本库的区别

$ git diff HEAD -- readme.txtdiff --git a/readme.txt b/readme.txtindex 5cedd61..c05c601 100644--- a/readme.txt+++ b/readme.txt@@ -1,3 +1,3 @@ git is a version control system. git is free software under the GPL.-git tracks changes.\ No newline at end of file+git tracks changes of files.\ No newline at end of file


0 0
原创粉丝点击