![](/img/trans.png)
[英]Why does git status for a particular repo return paths relative to the root instead of the current directory?
[英]git status: use absolute paths instead of relative
當我執行git status
,它顯示具有相對路徑的文件:
modified: foo
modified: ../../etc/hosts
相對路徑比絕對路徑更清晰。 我必須在精神上回溯路徑以查看文件所在的位置。
如何告訴git
使用絕對路徑?
modified: foo
modified: /etc/hosts
更新
正如@LightBender 所建議的,我在.gitconfig
設置了relativePaths = false
:
[status]
howUntrackedFiles = all
relativePaths = false
但是,這沒有效果。 git status
仍然像以前一樣顯示相對路徑。
如 git-status 文檔的配置部分所述:
您可以將配置值status.relativePaths
設置為 false,git 將顯示相對於項目根目錄(而不是系統根目錄)的路徑。
git config [--global|local] status.relativePaths true
作為旁注,我嘗試了一次,幾乎立即對必須在每條路徑的開頭輸入項目根目錄 ( :/
) 的魔法簽名或必須弄清楚我需要使用路徑的哪一部分感到惱火相對在一個命令中。 讓 git 總是向我顯示我需要在 git 命令中使用該文件的路徑,結果對我來說更可取。
不確定,但你可以試試
git status --porcelain
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.