Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

git - 如何处理主机存储库中标记为“未跟踪”的git子模块文件夹?(How to handle folder of git submodule which is marked as “untracked” in the host repo?)

I've got a code base in which I want to add another repo as a submodule to do some integration testing.

(我有一个代码库,我想在其中添加另一个回购作为子模块来进行一些集成测试。)

So following a tutorial I ran

(所以按照教程我跑了)

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

After that, a git status gives me this:

(之后, 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)

As you can see the .gitmodules file is new, but the whisky/ folder also appears as untracked.

(如您所见, .gitmodules文件是新文件,但是.gitmodules whisky/文件夹也显示为未跟踪。)

After this I committed the .gitmodules file, but the whisky/ folder still appears as untracked.

(之后,我提交了.gitmodules文件,但是.gitmodules whisky/文件夹仍然显示为未跟踪。)

How should I handle this?

(我该如何处理?)

Do I need to add the whisky/ folder also to the "host repo"?

(我是否还需要将whisky/文件夹添加到“主机存储库”中?)

Or do I need to add it to .gitignore ?

(还是我需要将其添加到.gitignore ?)

Or is there another way to handle this?

(还是有另一种方法来解决这个问题?)

All tips are welcome!

(欢迎所有提示!)

  ask by kramer65 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just rerun git submodule add <URL> .

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

Git will see whisky/ as a submodule and won't track its files.

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

You can check it through git diff --cached whisky/ (git will only see it as a particular commit)

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

After all, just commit it.

(毕竟,只需提交即可。)

See more here

(在这里查看更多)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...