Git:--git-dir显示所有文件丢失

时间:2018-11-13 15:33:31

标签: git

我有两个具有相同子模块的非常相似的存储库。 目录结构:

vss
vss/rcv-nginx
rgw
rgw/rcv-nginx

rgw目录(只有它!)发出请求状态时,它表明所有文件都被删除。其他类似项目则不会发生这种情况。

以下是git status命令:

# On vss
peter@peterpc:~/git/vss$ git --git-dir=rcv-nginx/.git status
On branch dev
Your branch is up-to-date with 'origin/dev'.
nothing to commit, working directory clean

# On vss/rcv-nginx
peter@peterpc:~/git/vss$ cd rcv-nginx/
peter@peterpc:~/git/vss/rcv-nginx$ git status
On branch dev
Your branch is up-to-date with 'origin/dev'.
nothing to commit, working directory clean

# On rgw:
peter@peterpc:~/git/rgw$ git --git-dir=rcv-nginx/.git status
On branch feature-rcv-11870_openresty-nginx
Your branch is up-to-date with 'origin/feature-rcv-11870_openresty-nginx'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .gitlab/merge_request_templates/Bug.md
        modified:   .gitlab/merge_request_templates/Feature.md
        deleted:    .idea/runConfigurations/Render_Dyrka_Configs.xml
        ...
        (all files marked as missing)

# on rgw/rcv-nginx
peter@peterpc:~/git/rgw$ cd rcv-nginx/
peter@peterpc:~/git/rgw/rcv-nginx$ git status
On branch feature-rcv-11870_openresty-nginx
Your branch is up-to-date with 'origin/feature-rcv-11870_openresty-nginx'.
nothing to commit, working directory clean

P.S。

我已经解决了这个问题(git --git-dir not working as expected),并且知道了解决方法,但问题仍然存在-为什么git在类似项目中的行为有所不同?

1 个答案:

答案 0 :(得分:0)

可能发生这种情况的原因是,该目录中的较早版本只有rcv-nginx是符号链接,后来我将其更改为独立链接,但仍保留了Git缓存。