Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git subdirectory which is ignored

Tags:

git

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.

like image 740
Sam Kong Avatar asked Jun 17 '13 21:06

Sam Kong


People also ask

Does Gitignore apply to subdirectories?

There are several locations where Git looks for ignore files. Besides looking in the root folder of a Git project, Git also checks if there is a . gitignore in every subdirectory. This way you can ignore files on a finer grained level if different folders need different rules.

Can you git ignore a folder?

Inside . gitignore , you can tell Git to ignore only a single file or a single folder by mentioning the name or pattern of that specific file or folder. You can also tell Git to ignore multiple files or folders using the same method.

What are ignored files in git?

Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are: dependency caches, such as the contents of /node_modules or /packages. compiled code, such as .o , .pyc , and .class files.


2 Answers

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.

like image 128
Martin Owen Avatar answered Sep 22 '22 05:09

Martin Owen


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

like image 32
mipadi Avatar answered Sep 22 '22 05:09

mipadi