有誰知道一個Git探測(絕對不是瓷器)來確定是否:編程git的狀態
- 有在回購編輯自上次提交和
- 無論是本地的HEAD是提前原產地/頭部
我正在尋找以編程方式確定這一點,因此希望不用瓷器和各種sed-fu解決這個問題。
有誰知道一個Git探測(絕對不是瓷器)來確定是否:編程git的狀態
我正在尋找以編程方式確定這一點,因此希望不用瓷器和各種sed-fu解決這個問題。
更新:如mentioned below由toupeira,您可以使用git status的--porcelain
選項(因爲犯6f15787,2009年9月,git的1.7.0)。
我在答覆中提到「What does the term porcelain mean in Git?」中指出:
也許
--porcelain
的意思這裏是
但是「瓷器腳本產生適合食用輸出」,即不會顯示前後信息:請參閱「What to add to 「git status --porcelain」 to make it behave like 「git status」?」:爲此,您仍然需要使用其他命令:請參閱「How to know if git repository has changes that have not been synchronized with server?」
初步回答2009
三月在瓷器命令,:
$ git diff HEAD
給你,因爲變化的最後一次提交(你會犯,如果你運行「git的承諾-A」) 。
一個可能等同於管道命令是:
$ git ls-files -m
上市的所有修改(工作目錄或索引)文件
如果您通過克隆別人的存儲庫中創建你的倉庫中,遠程「主」分支被複制到名爲「origin」的本地分支。你會得到你自己的「主」分支,而不是綁定到遠程倉庫。
總是有一個當前頭部,稱爲HEAD。 (這實際上是一個符號鏈接,git的/ HEAD,像參考文獻/頭/主文件中。)
運行「GIT中狀態」和分析輸出:
# On branch master
# Your branch is ahead of 'origin/master' by 11 commits.
#
更多細節中的SO問題「Why is Git telling me 「Your branch is ahead of ‘origin/master’ by 11 commits.」 and how do I get it to stop?」
可能等同於管道命令:用於列出所有
* git-for-each-ref
承諾,但需要分析輸出,以及...
再次,git ls-files could be used to produced the same result than a git status。
git ls-files --exclude-per-directory=.gitignore --exclude-from=.git/info/exclude \
--others \
--modified \
-t
git status
現在具有用於腳本目的的--porcelain
參數(以及用於解析機器替代-z
),這是優選的git ls-files
不顯示添加到索引文件。
太好了。非常感謝。 – 2009-03-01 14:16:22
「git ls-files --exclude-standard ...」會更簡單一些。 – 2009-03-01 15:38:15