繁体   English   中英

Windows上的Git:为什么我突然有一个以前跟踪过的未跟踪目录?

[英]Git on Windows: Why I suddenly have untracked directory that used to be tracked?

当我点击'git status'时,它显示2个文件夹,其中包含很久以前被跟踪的文件:

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       src/UI/Views/Shared/EditorTemplates/
#       src/Web/helpers/

nothing added to commit but untracked files present (use "git add" to track)

Git GUI没有按预期显示任何内容。

使用portablegit 1.7.1 ,但尝试了1.7.0.2 - 相同的结果。

是什么导致的?


$ cat .gitignore
.nu/*
lib/*
*~
*.swp
*.swo
*_ReSharper*
doc/*
RAPLM.suo
RAPLM.5.1.ReSharper.user
src/*/bin/*
src/*/obj/*
src/*/Debug/*
src/*/Release/*
src/Domain/unused

@Charles Bailey

lapsaarn@WW021198 /d/work/asdf (master)
$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       src/UI/Views/Shared/EditorTemplates/
#       src/Web/helpers/
nothing added to commit but untracked files present (use "git add" to track)

lapsaarn@WW021198 /d/work/asdf (master)
$ git add src/Web/helpers/

lapsaarn@WW021198 /d/work/asdf (master)
$ git add src/Web/helpers/*

lapsaarn@WW021198 /d/work/asdf (master)
$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       src/UI/Views/Shared/EditorTemplates/
#       src/Web/helpers/
nothing added to commit but untracked files present (use "git add" to track)

lapsaarn@WW021198 /d/work/asdf (master)
$

@Charles

$ git ls-tree -r HEAD | grep -i助手
100644 blob 843de27f850308786140a7c09f67b5ef99184630 src / web / helpers / HtmlHelperExtensions.cs

Charles Bailey在评论中正确地诊断出了这个问题:对一个不区分大小写的Os的“ git add ”。

它链接到msysgit的问题286 :“目录名称的大小写敏感性”,即使您将core.ignorecase设置为true,问题仍然存在(同样,对于目录 )。

当你添加“ src\\Web ”(大写' W ')时,如果索引已包含“ src\\web ”(小写' w '),它将不会添加任何内容。

提出补丁但被拒绝:

该文件夹似乎被列为未跟踪文件夹,因为directory_exists_in_index()尝试将旧名称与新名称进行比较,最终找不到新文件夹的匹配项(即使其中的文件仍然被跟踪!)。
编写了一个非常粗鲁的补丁(下面内省),试图解决这个问题。
现在......对于我的最小情况,这是有效的 - 该目录不再列为未跟踪。 但我强烈期望这是一个破坏补丁,至少出于以下原因:不区分大小写的比较应该打破二进制搜索,因为如果我在索引中有更多文件,套管应该返回错误的位置。

 dir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dir.c b/dir.c
index e05b850..c55a15c 100644
--- a/dir.c
+++ b/dir.c
@@ -444,7 +444,7 @@ static enum exist_status directory_exists_in_index(const char 
*dirname, int len)
                struct cache_entry *ce = active_cache[pos++];
                unsigned char endchar;

-               if (strncmp(ce->name, dirname, len))
+               if (strnicmp(ce->name, dirname, len))
                        break;
                endchar = ce->name[len];
                if (endchar > '/')
--
1.6.4.msysgit.0.2.gcb017.dirty

所以你需要:

  • 在工作目录中将“ Web ”更改为“ web ”(文件系统)
  • 或者在索引中的索引( git mv src/web src/Web )中将“ web ”更改为“ Web ”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM