【问题标题】:Configure git to always show absolute paths将 git 配置为始终显示绝对路径
【发布时间】:2021-05-20 09:12:53
【问题描述】:

如何配置 git 始终显示绝对路径?

git status -uno 的示例:

实际行为(相关路径):

    new file:   xxx/xxx.c

想要的行为(绝对路径):

    new file:   /home/zzz/xxx/xxx.c

【问题讨论】:

    标签: git path usability


    【解决方案1】:

    我认为你不能让git status 显示绝对路径,但你可以将其配置为显示相对于 git 根目录的路径,详情请参阅man git-status

    如果配置变量 status.relativePaths 设置为 false,则显示的所有路径都相对于存储库根目录,而不是当前目录。

    ~repo/src $ git status
    On branch master
    Your branch is up to date with 'origin/master'.
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
        a.txt
    

    ~repo/src $ git config --global status.relativePaths false
    
    ~repo/src $ git status
    On branch master
    Your branch is up to date with 'origin/master'.
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
        src/a.txt
    

    【讨论】:

    • show absolute paths 功能在git 中有用吗?
    猜你喜欢
    • 2017-04-20
    • 1970-01-01
    • 1970-01-01
    • 2013-03-07
    • 2016-04-26
    • 2016-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多