配置 git 始终显示绝对路径

问题描述

如何配置git总是显示绝对路径

git status -uno 的示例:

实际行为(相关路径):

    new file:   xxx/xxx.c

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

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

解决方法

我认为您无法让 git status 显示绝对路径,但您可以将其配置为显示相对于 git root 的路径,详情请参阅 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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...