在git中列出以../为前缀的文件

时间:2013-08-05 11:04:09

标签: git windows-7

我遇到了一个问题:当我从一个目录运行git status时,它会将此目录的许多文件列为../../../file,这实际上是我当前目录中没有任何父文件夹前缀的文件。 / p>

repo在D:/。git中,我当前的目录是/d/anurag/work/sources/webhosting/gij-sync-scripts,我使用git-bash命令shell。我的是git 1.8.3.msysgit.o版本。

我从未以这种方式添加文件。可能是什么导致了这个? enter image description here

这是我正在粘贴的文字版本(如上图所示):

> D14@D14-PC /d/anurag/work/sources/webhosting/gij-sync-scripts (master)
> $ git commit
> # On branch master
> # Changes not staged for commit:
> #   (use "git add <file>..." to update what will be committed)
> #   (use "git checkout -- <file>..." to discard changes in working directory)
> #
> #       modified:   ../../../../../Anurag/work/sources/webhosting/gij-sync-scripts/copy-site-files.pl
> #       modified:   ../../../../../Anurag/work/sources/webhosting/gij-sync-scripts/local-common.pl
> #       modified:   backup-gij.pl
> #       modified:   backup-joi.pl
> #       modified:   backup-nav.pl
> #       modified:   backupall.sh
> #       modified:   restoreall.sh
> #
> # Untracked files:
> #   (use "git add <file>..." to include in what will be committed)
> #
> #       ../../../../../.gitignore
> #       ../../../../../5632_20269334_MVM_7.tmp
> #       ../../../../../Anurag/work/admissioncourses.com/
> #       ../../../../../Anurag/work/govtjobsindia/
> #       ../../../../../Anurag/work/indiadiscountoffers.com/
> #       ../../../../../Anurag/work/jobsopeningindia.com/
> #       ../../../../../Anurag/work/sources/bookrailticket/.buildpath
> #       ../../../../../Anurag/work/sources/bookrailticket/.cvsignore

我运行此命令的当前目录是/d/anurag/work/sources/webhosting/gij-sync-scripts并包含这些已修改的文件(如我的Windows 7资源管理器中所示(使用TortoiseGit):

enter image description here

2 个答案:

答案 0 :(得分:1)

运行git status将为您提供有关整个存储库中文件的信息,而不仅仅是您当前所在的路径。路径将始终相对于您当前的目录显示,因此如果你不在回购的根目录中,你最终会得到一个数字f ../

e.g。从存储库根目录检查状态:

$ git status 
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   bar/knardel.c
#   modified:   baz/README.txt
#   modified:   foo/breslow.xml
#

但是检查子目录bar/中的状态会给您:

$ cd bar
$ git status 
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   knardel.c
#   modified:   ../baz/README.txt
#   modified:   ../foo/breslow.xml
#

如果您只想查看当前子目录及其子项的状态,可以将当前目录(.)设为<pathspec>

$ git status .
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   knardel.c
#

答案 1 :(得分:0)

您正在混合大写和大写文件名。 而对于Windows,路径D:\Anurag\work\sources\webhosting\gij-sync-scriptsD:\anurag\work\sources\webhosting\gij-sync-scripts可能是相同的,git(来自un * x世界,文件系统通常区分大小写),区分/d/Anurag/work/sources/webhosting/gij-sync-scripts/d/anurag/work/sources/webhosting/gij-sync-scripts

您可以使用core.ignorecase选项配置git(&gt; = 1.5.6)来忽略案例:

git config --global core.ignorecase true