【问题标题】:Running "git status" against a repository located elsewhere in the system针对位于系统其他位置的存储库运行“git status”
【发布时间】:2011-10-07 18:25:15
【问题描述】:

我知道我可以做到:

git --git-dir="Z:/www/proj/web/test/sample-repo-cloned/.git" status

但是,问题是该命令是从proj 文件夹运行的,这意味着所有位于sample-repo-cloned 之前的文件也会被考虑在内。

有没有办法在sample-repo-cloned文件夹范围内运行这个命令?

【问题讨论】:

    标签: windows linux git shell


    【解决方案1】:

    您应该能够指定工作树以及 git 目录:

    --work-tree
    

    即:

    git --work-tree="Z:/www/proj/web/test/sample-repo-cloned/" --git-dir="Z:/www/proj/web/test/sample-repo-cloned/.git"  status
    

    结果应该是工作树根目录的本地结果。

    【讨论】:

    • 请注意,并非所有命令都与遵守这些 git 级别选项一致。 Stash是我想到的一个。它似乎不起作用,或者至少在某些情况下可能与相对路径无关......
    • @Adam:是的,我看到了你的“Git Stash & Worktree Woes”的回答(赞成)(stackoverflow.com/questions/6392862/git-stash-worktree-woes)
    • 干杯 :) .. 围绕这些命令的代码采用不同的路径。没有我想象的那么容易修复。也许这个周末......
    【解决方案2】:

    (cd Z:/www/proj/web/test/sample-repo-cloned ; git status) 怎么了??

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-26
      • 2016-04-03
      • 2013-02-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-17
      • 2013-10-09
      相关资源
      最近更新 更多