Robin Hsu
Robin Hsu

Reputation: 4484

git repository in repository scenario: how to ignore repository subfolders (i.e. subfolders having .git/)

Suppose I have my repository structure like this:

MyApp/
    .git/
    .gitignore
    File1
    dir1/
        File2
    src/
        File3
        File4
        module1/
            .git/
            .gitignore
            foo.cpp
        module2/
            .git/
            .gitignore
            bar.cpp
        ...

In other words, I have some deep sub-folders containing .git/, called repository sub-folders.

How can I write .gitignore in MyApp repository, or by other means, to ignore all those repository sub-folders in the view of MyApp? They are obvious to be ignored, since they are already managed by other independent repositories.

--OR--

Any standard way to deal with this "Git: repository in repository" scenario, if the "ignoring" is not the way to go?

Upvotes: 0

Views: 63

Answers (2)

Pancho
Pancho

Reputation: 2193

I'm understanding your question correctly, then although not "automatically ignoring via .git identification", an easy way to ignore the module1,2....n sub trees is to create a .gitignore file in myApp/src folder and insert the value:

module*/

Then save the file and you should achieve the desired result.

Upvotes: 0

VonC
VonC

Reputation: 1324318

My intention is to automatically ignores folders containing .git/

Those folder contents are already ignored, as a main Git repo would only record them as gitlink (special entry in the index).
Here it would only record module1, module2 (not their content)

If you wanted to not record module1, you would still need a .gitignore (with simply a src/module*, no trailing slash as you do not ignore a folder, only a gitlink)
You cannot instruct git to automatically ignore a gitlink, you have to specify it in a .gitignore.

Upvotes: 1

Related Questions