在Windows上的Git:为什么我突然有一个跟踪的未跟踪目录? [英] Git on Windows: Why I suddenly have untracked directory that used to be tracked?

查看:158
本文介绍了在Windows上的Git:为什么我突然有一个跟踪的未跟踪目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  $ 

当我点击'git status'时,它显示2个包含很久以前被追踪的文件的文件夹: git status
#在分支主机上
#未记录文件:
#(使用git add< file> ...来包含在提交的内容中)

#src / UI / Views / Shared / EditorTemplates /
#src / Web / helpers /

没有添加提交但未跟踪的文件存在(使用git add来跟踪)

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
#分支主
#未追踪文件:
#(使用git add< file> ...来包含将要提交的内容)

#src / UI / Views / Shared / EditorTemplates /
#src / Web / helpers /
没有添加任何内容提交,但未跟踪的文件存在(使用git add跟踪)

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
#分支大师
#未追踪文件:
#(使用git add < file>包含在将要提交的内容中)

#src / UI / Views / Shared / EditorTemplates /
#src / Web / helpers /
没有添加任何提交但未跟踪的文件存在(使用git add来跟踪)

lapsaarn @ WW0 21198 / d / work / asdf(master)
$






@Charles


$ git ls-tree -r HEAD | grep -i helpers

100644 blob 843de27f850308786140a7c09f67b5ef99184630 src / web / helpers / HtmlHelperExtensions.cs


解决方案

Charles Bailey 在评论中正确诊断了问题: git在不区分大小写的Os上添加



它与 msggit的问题286 :目录名称的大小写敏感性,并且问题仍然存在(同样,对于目录),即使您设置 core.ignorecase 为true。



当您添加 src\Web (大写' W '),如果您的索引已经包含 src\web (小写字母 w ')。



A补丁被提出,但被拒绝:


该文件夹似乎是列为未追踪的,因为 directory_exists_in_index() 尝试将旧名称与新名称进行比较,最终未找到匹配
新文件夹(即使其中的文件仍然被追踪!)。

一个非常粗鲁的补丁(下面内联)是为解决这个问题而编写的。

现在.. 。对于我最小的情况,这是有效的 - 该目录不再列为未跟踪。但我强烈希望这是一个BROKEN补丁,至少有以下原因:不区分大小写的比较应该打破二进制搜索,因为如果索引中有更多文件,套管应该返回错误的位置。




  dir.c | 2 +  -  
1个文件已更改,1个插入(+),1个删除( - )

diff --git a / dir.cb / dir.c
索引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;
$ b - if(strncmp(ce-> name,dirname,len))
+ if(strnicmp(ce-> name,dirname,len))
break;
endchar = ce->名称[len];
if(endchar>'/')
-
1.6.4.msysgit.0.2.gcb017.dirty






所以你需要:


  • 在您的工作目录(filesystem)中将' Web '更改为' web '
  • 或者将索引()中的' web '更改为' Web git mv src / web src / Web )。


When i hit 'git status', it shows 2 folders that contains files that are tracked long time ago:

$ 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 shows nothing as expected.

Using portablegit 1.7.1, but tried 1.7.0.2 - same results.

What can cause that?


$ 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 helpers
100644 blob 843de27f850308786140a7c09f67b5ef99184630 src/web/helpers/HtmlHelperExtensions.cs

解决方案

Charles Bailey correctly diagnosed the problem in the comments: "git add" on a case insensitive Os.

It is linked to issue 286 of msysgit: "Case Sensitity of Directory Names", and the issue remains (again, for directories) even if you set core.ignorecase to true.

When you add "src\Web" (with a capital 'W'), it won't add anything if your index already contains "src\web" (lowercase 'w').

A patch was proposed but rejected:

The folder seems to be listed as untracked because directory_exists_in_index() tries to compare the old name to the new name, and ending up not finding a match for the new folder (even though the file inside it remains tracked!).
A very rude patch (inlined below) was written to try to work around the issue.
Now... for my minimal case, this works - the directory is no longer listed as untracked. But I strongly expect this to be a BROKEN patch for at least the following reason: Case insensitive comparison should break binary searching, as the casing should return the wrong position if I had more files in the 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


So you need to:

  • change your 'Web' into 'web' in your working directory (filesystem)
  • OR change your 'web' into 'Web' in the index (git mv src/web src/Web) in your index.

这篇关于在Windows上的Git:为什么我突然有一个跟踪的未跟踪目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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