Sam Kong
Sam Kong

Reputation: 5800

git subdirectory which is ignored

I have a project named 'myproject' which is version-controlled by git. It has a subdirectory named 'data' which is gitignored.

Can I 'git init' for data directory and manage it as a separate git tree? I tested it and it seems to work. But I am not sure if that's a good practice and has potential problems.

Upvotes: 6

Views: 66

Answers (2)

Martin Owen
Martin Owen

Reputation: 5271

If the parent repository depends on the 'data' repository being a specific version, you might want to consider git submodules. This will allow the parent repository to point to a specific commit of the 'data' repository. Even if the two are compatible now they may not be in the future.

I don't have much detail on your use-case and how 'myproject' relates to 'data', so submodules may over-complicate things for you.

Upvotes: 7

mipadi
mipadi

Reputation: 410552

Yep, that should be fine. I've done that many times before, with no problems.

Upvotes: 1

Related Questions