获取父文件夹文件的Git状态 [英] Git status picking up parent folder's files
问题描述
我刚刚在 htdocs / project
中创建了一个新项目,当我使用状态来获取该文件夹中的文件时,它列出了包含的文件和目录在 htdocs / project
中,但它也列出了 htdocs
的所有文件夹和子项。
例如:
#变更未进行commit:
#modified:../otherproject/index.php
#modified:../project3/index.php
#未记录文件:
#../otherproject /blah.txt
#../project3/img/lol.jpg
如果它有助于我使用Git Bash Here选项将我的Git目录更改为 htdocs / project
。
'htdocs'本身就是一个git回购?
ls htdocs / .git
如果是这样,那就可以解释你所看到的 - 一个git repo不能在其中有另一个repo。
(因为我没有足够的柿子,所以作为回答而不是评论发布。)
编辑:根据下面的讨论,这似乎是问题所在。根据 http://progit.org/book/ch6-4.html :
使一个子目录成为新的根目录
假设你已经完成了从另一个源代码控制系统的导入,具有无意义的子目录
(主干,标签等)。如果您希望将trunk子目录设为
作为每次提交的新项目根目录,filter-branch也可以帮助您执行此操作:
$ git filter-branch --subdirectory-filter trunk HEAD
Rewrite 856f0bf61e41a27326cdae8f09fe708d679f596f(12/12)
Ref'refs / heads / master'被重写
现在你的新项目根目录是每次在trunk子目录中的内容。 Git也将$ b $ b自动删除不影响子目录的提交。
我自己并没有这样做,所以希望有人会自愿提供一些经验。
I've just created a new project in htdocs/project
and when I use a status to pick up the files in that folder it is listing the files and directories contained in htdocs/project
but it is also listing all the folders and children of htdocs
as well.
For example:
# Changes not staged for commit:
# modified: ../otherproject/index.php
# modified: ../project3/index.php
# Untracked files:
# ../otherproject/blah.txt
# ../project3/img/lol.jpg
If it helps I used the "Git Bash Here" option to change my Git directory to htdocs/project
.
Is 'htdocs' itself a git repo?
ls htdocs/.git
If so, that would explain what you're seeing - a git repo can't have another repo within it.
(Posted as an answer rather than a comment because I don't have enough persimmons.)
Edit: Based on the discussion below, this seems to be the problem. According to http://progit.org/book/ch6-4.html:
Making a Subdirectory the New Root
Suppose you’ve done an import from another source control system and have subdirectories
that make no sense (trunk, tags, and so on). If you want to make the trunk subdirectory be
the new project root for every commit, filter-branch can help you do that, too:
$ git filter-branch --subdirectory-filter trunk HEAD
Rewrite 856f0bf61e41a27326cdae8f09fe708d679f596f (12/12)
Ref 'refs/heads/master' was rewritten
Now your new project root is what was in the trunk subdirectory each time. Git will also
automatically remove commits that did not affect the subdirectory.
I haven't done this myself, so hopefully someone who has will volunteer some experiences.
这篇关于获取父文件夹文件的Git状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!