如何处理git子模块的文件夹,该文件夹在主机存储库中标记为“未跟踪”?

问题描述 投票:1回答:1

我有一个代码库,我想在其中添加另一个回购作为子模块来进行一些集成测试。因此,按照教程我跑了

git submodule add -b master [email protected]:kramer65/whisky.git

之后,git status给了我这个:

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .gitmodules
    whisky/

nothing added to commit but untracked files present (use "git add" to track)

您可以看到.gitmodules文件是新文件,但whisky/文件夹也显示为未跟踪。此后,我提交了.gitmodules文件,但whisky/文件夹仍然显示为未跟踪。

我该如何处理?我是否还需要将whisky/文件夹添加到“主机存储库”中?还是我需要将其添加到.gitignore?还是有其他方法可以解决这个问题?

欢迎所有提示!

git version-control integration-testing git-submodules
1个回答
0
投票

只需重新运行git submodule add <URL>

Git将把whisky /作为子模块,并且不会跟踪其文件。

您可以通过git diff --cached whisky/进行检查(git只会将其视为特定的提交)

毕竟,只需提交即可。

See more here

© www.soinside.com 2019 - 2024. All rights reserved.