Git学习第二章第一节

版本控制

        修改test.txt,随便加减点东西。

        再运行 git status 命令查看结果(我测试用的是readme.txt)

$ 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")

        git status是让我们时刻掌握仓库当前的状态,上面的命令告诉我们,readme.txt被修改过了,但还没有准备提交的修改。

        虽然知道了readme.txt被修改了,但是具体修改了什么并不知道,通过git diff 命令来查看改了什么。

$ git diff
diff --git a/readme.txt b/readme.txt
index d8036c1..eb02596 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,3 @@
 Git is a version control system.
-Git is free software.
\ No newline at end of file
+Git is free software.
+Git is a distributed version control system
\ No newline at end of file

        确定修改的内容后,再提交到仓库中,提交修改和提交新文件是一样的两步,第一步git add

        运行后和上次一样没有返回信息就是成功的。在运行git commit -m "add a line"

$ git commit -m "add a line"
[master 4cf9a97] add a line
 1 file changed, 2 insertions(+), 1 deletion(-)

        再运行git status后回给我们当前没有需要提交的修改,而且工作目录是干净的。

$ git status
On branch master
nothing to commit, working tree clean

        

猜你喜欢

转载自blog.csdn.net/endless_fighting/article/details/79712027
今日推荐