为什么被排除的文件不断重现在我的git sparse checkout中? [英] Why do excluded files keep reappearing in my git sparse checkout?

查看:166
本文介绍了为什么被排除的文件不断重现在我的git sparse checkout中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 GCC git镜像,因为我只使用C和C ++前端I使用git的稀疏结帐功能来排除我不需要的数百个文件:

  $ git config core.sparseCheckout 
true
$ cat .git / info / sparse-checkout
/ *
!gnattools /
!libada /
!libgfortran /
!libgo /
!libjava /
!libobjc /
!libquadmath /
!gcc / ada /
!gcc / fortran /
!gcc / go /
!gcc / java /
!gcc / objc /
!gcc / objcp /
!gcc / testsuite / ada /
!gcc / testsuite / gfortran.dg /
!gcc / testsuite / gfortran.fortran-torture /
!gcc / testsuite / gnat.dg /
!gcc / testsuite / go.dg /
!gcc / testsuite / go .go-torture /
!gcc / testsuite / go.test /
!gcc / testsuite / objc /
!gcc / testsuite / objc.dg /
!gcc / testsuite /obj-c++.dg/
!gcc / testsuite / objc-obj-c ++ - shared /

这有一段时间,但我偶尔会注意到这一点这些被排除的文件已经返回,有时甚至是很多:

  $ ls gnattools / 
ChangeLog configure configure.ac Makefile.in
$ ls gcc / fortran / | wc -l
86

我不确定文件何时重新出现,我确实很多转换到不同的分支(远程跟踪和本地),这是一个非常繁忙的回购,所以有新的变化拉动经常。



作为一个相对的新手git我不知道如何重置我的工作树以再次清除这些文件。



作为一个实验,我尝试禁用稀疏检出和拉动,思考之后我可以启用sparseCheckout来以某种方式更新树,但是这样做效果不佳:

  $ git config core。 sparseCheckout false 
$ git config core.sparseCheckout
false
$ git pull
remote:计数对象:276,完成。
remote:压缩对象:100%(115/115),完成。
remote:合计117(delta 98​​),重用0(delta 0)
接收对象:100%(117/117),64.05 KiB,完成。
解析三角洲:100%(98/98),完成64个本地对象。
从git://gcc.gnu.org/git/gcc
7618909..0984ea0 gcc-4_5-branch - > origin / gcc-4_5-branch
b96fd63..bb95412 gcc-4_6-branch - > origin / gcc-4_6-branch
d2cdd74..2e8ef12 gcc-4_7-branch - > origin / gcc-4_7-branch
c62ec2b..fd9cb2c master - >原产地/主人
2e2713b..29daec8熔断枝 - >起源/熔化分支
c62ec2b..fd9cb2c中继线 - > origin / trunk
正在更新c62ec2b..fd9cb2c
错误:对以下文件的本地更改将被合并覆盖:
gcc / fortran / ChangeLog
gcc / fortran / iresolve。 c
libgfortran / ChangeLog
libgfortran / io / intrinsics.c
请在提交您的更改或隐藏它们之前进行合并。
正在取消

显然,我已经对我从未要求过的文件进行了本地修改,并且AFAIK从未触及!



git status 不显示这些更改:

  $ git st 
#在分支master上
#你的分支在9次提交后落在'origin / master'后面,转发。

#未记录的文件:
#(使用git add< file> ...来包含将要提交的内容)

#libstdc ++ -v3 / 53270.txt
#libstdc ++ - v3 / TODO

code> git read-tree -m -u HEAD 但它什么也没有做。



所以我的问题是:




  • 为什么文件重新出现?

  • 如何让它们再次消失?

  • 我如何阻止他们回来?

  • 这可能与我的 .git / info / exclude 文件包含对稀疏检出中应该排除的目录中的文件的引用(即用命名) code>文件?我按照指示忽略了与SVN相同的文件



    $ git svn show-ignore>> .git / info / exclude




所以我的 / code>文件包含如下路径:

 #/ gcc / fortran / 
/ gcc / fortran / TAGS
/gcc/fortran/TAGS.sub
/gcc/fortran/gfortran.info*

其中一个目录位于 sparse-checkout 文件中指定的目录之下:



<$ p $我已经尝试重现问题了。我已经尝试重现这个问题了。我已经尝试重现这个问题了。

!gcc / fortran /

用一个测试回购,我克隆了几个副本并编辑它们,创建/切换/删除分支并合并它们之间的变化,但它在我的玩具测试用例中永远不会出错。海湾合作委员会的回购有点大(超过2GB),失败(大约一两周)之间的时间太长,以至于人们无法准确地重现问题。我没有在 sparse-checkout exclude 中使用相同的路径进行实验,因为它今天才发生在那里可能有冲突。

几周前我在freenode的#git上询问了这个问题,并且IIRC基本上被告知很可能一个错误,没有人使用稀疏结帐,但我希望有更好的答案; - )



更新:



最近我发现问题实际发生了(即文件不存在,然后出现在一个命令后)正在从上游原点拉动:

  bac6f1f..6c760a6 master  - >起源/大师

以及显示的更改包括这些重命名:

 创建模式100644 libgo / go / crypto / x509 / root.go 
重命名libgo / go / crypto / {tls => x509} /root_darwin.go(90%)
重命名libgo / go / crypto / {tls => x509} /root_stub.go(51%)
重命名libgo / go / crypto / {tls => x509} /root_unix.go(76%)
创建模式100644 libgo / go / crypto / x509 / root_windows.go

根据需要,在拉动 libgo 目录之前,该目录不存在。在dir出现之后,这些文件(以及其他文件)不在其下:

  $ ls libgo / go / crypto / X509 / root_<标签> 
root_darwin.go root_stub.go root_unix.go

我不知道重命名文件丢失了 skip-worktree 位,我该如何检查?



我很确定问题没有解决有重命名时总是会发生,因为例如上面示例中显示的 libgfortran / ChangeLog 文件不是新文件或最近重命名的文件。

skip-worktree位可以用 git update-index --skip-worktree 修改。当你注意到这些文件出现时,你可以检查 git ls-files -v | grep ^ S (S是一个标有skip-worktree的文件)。



但是正如#git人们所说的,如果你看到奇怪的行为,那很可能是git中的一个bug。毕竟,这是相当深奥的特征。您应该将您的发现报告给git邮件列表。



编辑:另外,如果您使用的是git 1.7.7.6,我强烈建议升级。 1.7.10树是遥遥领先的,我认为它很有可能解决你的问题。


I use the GCC git mirror and because I only use the C and C++ front ends I use git's sparse checkout feature to exclude the hundreds of files I don't need:

$ git config core.sparseCheckout
true
$ cat .git/info/sparse-checkout 
/*
!gnattools/
!libada/
!libgfortran/
!libgo/
!libjava/
!libobjc/
!libquadmath/
!gcc/ada/
!gcc/fortran/
!gcc/go/
!gcc/java/
!gcc/objc/
!gcc/objcp/
!gcc/testsuite/ada/
!gcc/testsuite/gfortran.dg/
!gcc/testsuite/gfortran.fortran-torture/
!gcc/testsuite/gnat.dg/
!gcc/testsuite/go.dg/
!gcc/testsuite/go.go-torture/
!gcc/testsuite/go.test/
!gcc/testsuite/objc/
!gcc/testsuite/objc.dg/
!gcc/testsuite/obj-c++.dg/
!gcc/testsuite/objc-obj-c++-shared/

This works for a while, but then now and then I notice that some of those excluded files have returned, sometimes lots of them:

$ ls gnattools/
ChangeLog  configure  configure.ac  Makefile.in
$ ls  gcc/fortran/ | wc -l 
86

I'm not sure exactly when the files reappear, I do a lot of switching to different branches (both remote-tracking and local) and it's a very busy repo so there are new changes to pull frequently.

As a relative newbie to git I don't know how to "reset" my work tree to get rid of those files again.

As an experiment, I tried disabling sparse checkout and pulling, thinking I could enable sparseCheckout again afterwards to update the tree somehow, but that didn't work very well:

$ git config core.sparseCheckout false
$ git config core.sparseCheckout 
false
$ git pull
remote: Counting objects: 276, done.
remote: Compressing objects: 100% (115/115), done.
remote: Total 117 (delta 98), reused 0 (delta 0)
Receiving objects: 100% (117/117), 64.05 KiB, done.
Resolving deltas: 100% (98/98), completed with 64 local objects.
From git://gcc.gnu.org/git/gcc
   7618909..0984ea0  gcc-4_5-branch -> origin/gcc-4_5-branch
   b96fd63..bb95412  gcc-4_6-branch -> origin/gcc-4_6-branch
   d2cdd74..2e8ef12  gcc-4_7-branch -> origin/gcc-4_7-branch
   c62ec2b..fd9cb2c  master     -> origin/master
   2e2713b..29daec8  melt-branch -> origin/melt-branch
   c62ec2b..fd9cb2c  trunk      -> origin/trunk
Updating c62ec2b..fd9cb2c
error: Your local changes to the following files would be overwritten by merge:
        gcc/fortran/ChangeLog
        gcc/fortran/iresolve.c
        libgfortran/ChangeLog
        libgfortran/io/intrinsics.c
Please, commit your changes or stash them before you can merge.
Aborting

So apparently I've got local modifications to files I never asked for and AFAIK have never touched!

But git status doesn't show those changes:

$ git st
# On branch master
# Your branch is behind 'origin/master' by 9 commits, and can be fast-forwarded.
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       libstdc++-v3/53270.txt
#       libstdc++-v3/TODO

I've tried git read-tree -m -u HEAD but it doesn't do anything.

So my questions are:

  • Why do the files reappear?
  • How do I make them disappear again?
  • How do I prevent them coming back?
  • Is this possibly related to the fact my .git/info/exclude file contains references to files in the directories supposed to be excluded (i.e. named with !) in the sparse-checkout file? I followed the instructions to ignore the same files that SVN does

    $ git svn show-ignore >> .git/info/exclude

So my exclude files includes paths such as

# /gcc/fortran/
/gcc/fortran/TAGS
/gcc/fortran/TAGS.sub
/gcc/fortran/gfortran.info*

Which would be below one of the directories named in the sparse-checkout file:

!gcc/fortran/

I've tried to reproduce the problem with a test repo that I clone a few copies of and edit each of them, create/switch/delete branches and merge changes between them, but it never goes wrong in my toy testcases. The GCC repo is a bit big (over 2GB) and the time between "failures" (on the order of a week or two) too long to expect people to try to reproduce the problem exactly. I haven't experimented with having the same paths in sparse-checkout and exclude, as it only occurred to me today there might be a conflict there.

I asked about this on #git on freenode a few weeks ago and IIRC was basically told "it's probably a bug, noone uses sparse checkout" but I'm hoping for a better answer ;-)

Update:

The most recent time I saw the problem actually happen (i.e. the files weren't there, then appeared after a single command) was doing a pull from the upstream origin:

   bac6f1f..6c760a6  master     -> origin/master

and among the changes shown were these renames:

 create mode 100644 libgo/go/crypto/x509/root.go
 rename libgo/go/crypto/{tls => x509}/root_darwin.go (90%)
 rename libgo/go/crypto/{tls => x509}/root_stub.go (51%)
 rename libgo/go/crypto/{tls => x509}/root_unix.go (76%)
 create mode 100644 libgo/go/crypto/x509/root_windows.go

Before the pull the libgo directory was absent, as desired. After the pull that dir was present and these files (and no others) were under it:

$ ls libgo/go/crypto/x509/root_<TAB>
root_darwin.go  root_stub.go    root_unix.go    

I don't know if the renamed files lost their skip-worktree bit, how do I check that?

I'm pretty sure the problem doesn't always happen when there are renames, because e.g. the libgfortran/ChangeLog file shown in an example above is not a new file or recently renamed.

解决方案

The skip-worktree bit can be modified with git update-index --skip-worktree. When you notice the files present you can check git ls-files -v |grep ^S (S being a file marked with skip-worktree).

But as the #git folks say, if you see odd behavior it is most likely a bug in git. After all, this is quite esoteric feature. You should probably report your findings to the git mailing list.

Edit: Also, if you are using git 1.7.7.6, I strongly recommend upgrading. 1.7.10 tree is way ahead, and I think there is a strong chance it will fix your problems.

这篇关于为什么被排除的文件不断重现在我的git sparse checkout中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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