3

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

存储库位于 D:/.git 中,我当前的目录是/d/anurag/work/sources/webhosting/gij-sync-scripts并且我使用 git-bash 命令 shell。我的是 git 1.8.3.msysgit.o 版本。

我从来没有以这种方式添加文件。这可能是什么原因造成的?在此处输入图像描述

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

> 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):

在此处输入图像描述

4

2 回答 2

1

runninggit status将为您提供有关整个存储库中文件的信息,而不仅仅是您当前所在的路径。路径将始终相对于您当前的目录显示,因此如果您不在 repo 的根目录中,您将最终带有数字 f../

例如从存储库根检查状态:

$ 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
#
于 2013-08-05T11:12:01.470 回答
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

您可以使用以下选项配置 git (>=1.5.6) 以忽略案例core.ignorecase

git config --global core.ignorecase true
于 2013-08-05T11:48:03.780 回答