Git — 版本管理

Git 版本管理

修改已經提交的 readme.txt 文件:

Git is a distributed version control system.
Git is free software.
查看 git 庫狀態

執行 git status 命令查看結果:

$ 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 被修改過,但還沒有準備提交的修改。
查看 git 庫具體修改內容

使用 git diff 命令查看具體修改內容:

$ git diff readme.txt
diff --git a/readme.txt b/readme.txt
index 46d49bf..9247db6 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
-Git is a version control system.
+Git is a distributed version control system.
 Git is free software.
  • git diff 就是查看 difference,顯示的格式正是 Unix 通用的 diff 格式
查看 add 和 commit 之後的狀態
  1. 執行 git add 之後,執行 git status 查看狀態:

    $ git status
    On branch master
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
    	modified:   readme.txt
    
  2. 執行 git commit 之後,執行 git status 查看狀態:

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

注意:可以看出,當前沒有需要提交的修改,工作目錄是乾淨的(working tree clean)。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章