为什么特定repo的git状态会返回相对于根目录而不是当前目录的路径? [英] Why does git status for a particular repo return paths relative to the root instead of the current directory?

查看:112
本文介绍了为什么特定repo的git状态会返回相对于根目录而不是当前目录的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当从一个特定的repo中的子目录使用git时,这些文件的路径将相对于根返回,如下所示:

  cd $ REPO_ROOT / subdir 
git status
...
#modified ../subdir/file.txt

这种行为是最近的,它用来返回 file.txt ,就像我的其他git仓库一样,它是搞乱其他功能, git blame file.txt 从子目录返回每一行为 Not Yet committed ,以获取实际输出我需要使用 ../ subdir / file.txt



我已经运行了 git gc 这也是搞乱了vim git插件,所以我非常恼火。但问题仍然存在。



编辑:添加git版本和配置

  git version 1.7.4.4 

user.name = ...
user.email = ...
github.user = ...
color.branch = auto
color.diff = auto
color.status = auto
color.branch.current =黄色反转
color.branch.local =黄色
color.branch .remote = green
color.diff.meta =黄色粗体
color.diff.frag =洋红色粗体
color.diff.old =红色
color.diff.new =绿色
color.status.added = green
color.status.changed = red
color.status.untracked = cyan

core.repositoryformatversion = 0
core.filemode = true
core.bare = false
core.logallrefupdates = true
core.ignorecase = true

#remotes和branches

status.relativepaths = true


解决方案

这是一个配置文件离子问题:

  cd回购​​
git config status.relativePaths true



或全局:

  git config --global status.relativePaths true 

更多阅读材料: https://www.kernel.org/pub/software/scm/git/docs/git-status.html


When using git from a subdirectory inside a particular repo the paths of the files are returned relative to the root, like so

cd $REPO_ROOT/subdir
git status
...
#   modified ../subdir/file.txt

This behaviour is recent, it used to return file.txt instead, just as is does with my other git repos and it's messing up other features, git blame file.txt from the subdirectory returns every line as Not Yet committed, to get the actual output I need to use ../subdir/file.txt. This is also messing up the vim git plugin so I'm quite annoyed.

I have already run git gc but the problem persists.

edit: adding git version and configs

git version 1.7.4.4

user.name=...
user.email=...
github.user=...
color.branch=auto
color.diff=auto
color.status=auto
color.branch.current=yellow reverse
color.branch.local=yellow
color.branch.remote=green
color.diff.meta=yellow bold
color.diff.frag=magenta bold
color.diff.old=red
color.diff.new=green
color.status.added=green
color.status.changed=red
color.status.untracked=cyan

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

#remotes and branches 

status.relativepaths=true

解决方案

It is a configuration issue:

cd repo
git config status.relativePaths true

Or global:

git config --global status.relativePaths true

Further reading: https://www.kernel.org/pub/software/scm/git/docs/git-status.html

这篇关于为什么特定repo的git状态会返回相对于根目录而不是当前目录的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆