2017-04-18 41 views
1

我用git fetch <remote> --depth=<N>避开超时问题添加远程到我的本地存储库。尝试git fetch <remote>没有指定深度会超时。所以我尝试了git fetch <remote> --depth=10,然后反复多次,每次都稳步增加深度,直到我终于能够获得整个事物(即增加深度检索零对象)。之后我跑git fetch <remote> --unshallow其中is supposed to convert the remote back to a non-shallow remote copy与每个提取后更改远程分支git问题

这是我的问题。完成所有这些之后,我不确定我的本地存储库是否处于相同/相同状态,如果我刚开始时完成了git fetch <remote>,并且没有超时。每次我git fetch <remote>它不断报告相同的“新”和“更新”分支。

发生了什么,我该如何纠正?

我唯一能想到的尝试就是我没有真正尝试过,就是删除远程并重新添加它。我害怕不得不重新开始。这是一个非常大的存储库,需要很长时间才能达到这一点。如果我在此期间避免了git gc,将删除并重新添加远程分支,而无需再次下载所有提交?

以下是我所做的和结果。

每次我git fetch <remote>现在,不管我怎么努力,我得到这样的输出:

Fetching <remote> 
From ssh://<url> 
+ 3603285...775e0fe Feature/A -> <remote>/Feature/A (forced update) 
+ 6303337...de89a23 Feature/B -> <remote>/Feature/B (forced update) 
* [new branch]  feature/C -> <remote>/feature/C 
* [new branch]  feature/D -> <remote>/feature/D 
* [new branch]  feature/E -> <remote>/feature/E 
* [new branch]  feature/F -> <remote>/feature/F 
* [new branch]  feature/G -> <remote>/feature/G 
* [new branch]  feature/H -> <remote>/feature/H 

同样的输出每次。其他遥控器并不像这样。它只出现在这个远程,分支指针实际上从来没有实际进展,每个fetch试图再次推进它们。输出中永远不会有任何实际的错误。

我已经验证这些分支都存在于远程服务器中,并且不会在那里删除。但是,检查远程回购的分支Feature/A的整个提交历史记录,它根本不包含提交3603285

输出的

git config --get remote.<remote>.fetch

+refs/heads/*:refs/remotes/<remote>/* 

部分输出的git remote show <remote>

Remote branches: 
    feature/X      tracked 
    feature/Y      tracked 
    feature/A      tracked 
    feature/B      tracked 
    refs/remotes/<remote>feature/C stale (use 'git remote prune' to remove) 
    refs/remotes/<remote>feature/D stale (use 'git remote prune' to remove) 
    refs/remotes/<remote>feature/E stale (use 'git remote prune' to remove) 
    refs/remotes/<remote>feature/F stale (use 'git remote prune' to remove) 
    refs/remotes/<remote>feature/G stale (use 'git remote prune' to remove) 
    refs/remotes/<remote>feature/H stale (use 'git remote prune' to remove) 

事情我已经试过这没有纠正这一点,

  • git fsck(未报告任何问题)
  • git fetch <remote> --unshallow(报告资料库已经完成)
  • git gc(没有错误报告,运行两次产生相同的输出)
  • git remote prune <remote>(删除分支CH,但他们加了回去未来fetch
  • git fetch --all --prune

git fetch --all --prune输出是有点不同(也每一次,不管我怎么努力):

Fetching <remote> 
From ssh://<url> 
x [deleted]   (none)  -> <remote>/Feature/C 
x [deleted]   (none)  -> <remote>/Feature/D 
x [deleted]   (none)  -> <remote>/Feature/E 
x [deleted]   (none)  -> <remote>/Feature/F 
x [deleted]   (none)  -> <remote>/Feature/G 
x [deleted]   (none)  -> <remote>/Feature/H 
+ 3603285...775e0fe Feature/A -> <remote>/Feature/A (forced update) 
+ 6303337...de89a23 Feature/B -> <remote>/Feature/B (forced update) 
* [new branch]  feature/C -> <remote>/feature/C 
* [new branch]  feature/D -> <remote>/feature/D 
* [new branch]  feature/E -> <remote>/feature/E 
* [new branch]  feature/F -> <remote>/feature/F 
* [new branch]  feature/G -> <remote>/feature/G 
* [new branch]  feature/H -> <remote>/feature/H 

如果我退房分支<remote>/Feature/A我得到承诺3603285775e0fe,即使在远程服务器上,Feature/A775e0fe3603285是无处在它的历史。我也可以通过提交字符串直接检查出775e0fe,没有问题。命令该序列产生令我感到奇怪的输出(也每一次,不管我怎么努力):

$ git checkout <remote>/Feature/A 
HEAD is now at 3603285 
$ git checkout -b Feature/A 
$ git merge 775e0fe 
Already up-to-date. 
+0

我以前在使用案例折叠的系统上看到过这种行为。我看到你在这里有'feature/'和'Feature/',这里有小写字母和大写字母F.如果这是同样的问题,就是这样。你的Git认为它必须销毁错误的分支并创建正确的分支,但是你仍然有错误的名称,因为你的操作系统会折叠大小写并将所有内容写入现有的其他大小写目录。解决方案是使用不折叠大小写的OS(或文件系统),或者修复上游以使用单个大小写。 – torek

+0

@torek这是完全正确的。远程回购包含具有不同提交的'Feature/A'和'Feature/B'的大小写版本。并且所有'[删除的]'分支都被修剪为'特征/ ...',然后以小写形式添加回'特征/ ...'。添加您的解决方案并作为答案,我会接受它。 – wberry

回答

0

这是一个文件系统的情况下折叠的问题,所以它无关,与浅部(其是好消息/坏消息)。

我看你有没有这两个feature/<name>Feature/<name>这里,用小写和大写F.你的Git版本库中设置了这些,但一旦它创建一个目录有一个情况下,与其他情况下的分支名称在同去目录。然后你的Git认为这是错误的:它必须销毁错误的分支并创建正确的分支,但是你仍然有错误的名字,因为你的操作系统再次折叠大小写并且写入所有内容到现有的其他案例目录。

通常的解决方案是使用不折叠大小写的操作系统(或文件系统),或修复上游以使用单个大小写。

如果这是不可能的,我有一个想法,我从来没有测试过,但应该工作:你可以分裂你的fetch网址。这有很多缺点,主要是你必须偶尔手动运行git ls-remote并检查是否需要更新URL映射。 (使用其中一种更常用的解决方案要好得多。)

+0

宾果!我正在使用Windows,远程服务器几乎可以肯定是Linux,然后进入'.git'文件夹,我可以准确地看到您描述的内容。此外,遥控器确实有两个分支:“特征/ A”和“特征/ A”等。所以这几乎肯定是正确的解释。现在我知道我的本地回购没有损坏,在我的情况下,我可以放心地忽略这些分支,所以我会将分割取回解决方案的尝试留给其他人。 – wberry