There are some files in this repository, one of the files is untracked, which file is it?
倉庫中有一個文件是未被 Git 管理的,請問是哪一個文件?
Git 管理下的文件有多種狀態(tài),在工作中你經(jīng)常需要先查詢文件狀態(tài)才能決定下一步做什么或怎么做,所以它的重要性和 Linux 的 ls
命令是一樣重要的,是幾乎所有操作的起點。
查看倉庫狀態(tài)的命令是:
$ git status
$ git status -s
第1條命令表示以詳細(xì)格式查看,第2條命令表示以緊湊格式查看。默認(rèn)的詳細(xì)格式包含以下內(nèi)容:
untracked:倉庫里新建的文件,或者從別的地方復(fù)制到倉庫里的文件,它們的狀態(tài)都是 "untracked",它們被用紅字顯示在查詢結(jié)果的 "Untrakced files" 段落中。
modified:被編輯過的文件的狀態(tài)就變?yōu)?"modified",它們被用紅字顯示在查詢結(jié)果的 "Changes not staged for commit" 段落中。
git add
命令加入到暫存區(qū)的文件的狀態(tài)就變?yōu)?"staged",它們被用綠字顯示在查詢結(jié)果的 "Changes to be committed" 段落中。如果上面的狀態(tài)把你搞亂了,請翻到前面第3關(guān),再仔細(xì)看一下“Git 文件生命周期”那張圖。
第9關(guān)和第10關(guān)考核是正是你對 git status 查詢結(jié)果的閱讀能力,第9關(guān)是要你從查詢結(jié)果中識別出 untracked 狀態(tài)的文件。
第9關(guān)過關(guān)畫面如下:
http://wiki.jikexueyuan.com/project/githug-walkthrough/images/level-9-status.png" alt="第9關(guān) status" />