I'm having python script to download dependencies for my library (that is extracted as git repository) and it adds lines to .git/info/exclude
for git repository. But when it's extracted as submodule no .git/info/exclude file exists and i still need to exclude some paths without adding them to '.gitignore'. Any change to do it?
repo
├─.git
│ └─info
│ └─exclude
└─mylibrary (as_submodule)
├─extract_deps.py
└─some_dep (created by `extract_deps.py` and should be excluded)
In the picture above i need to exclude some_dep
from git changes.
Adding mylibrary/some_dep
to repo/.git/info/exclude
does not help since git status
still shows that mylibrary/some_dep
is added and untracked.
ANSWER: No, you don't need to add your submodule to your . gitignore : what the parent will see from your submodule is a gitlink (a special entry, mode 160000 ). That means: any change directly made in a submodule needs to be followed by a commit in the parent directory.
Ignoring untracked files To ignore untracked files, you have a file in your git folder called . git/info/exclude . This file is your own gitignore inside your local git folder, which means is not going to be committed or shared with anyone else. You can basically edit this file and stop tracking any (untracked) file.
Seems that git adds another structure for modules in mainrepo/.git/modules/path-to-submodule/info/exclude
.
Adding path to your model:
repo
├─.git
│ ├─info
│ ├─└─exclude
│ └─modules
│ └─mylibrary
│ └─info
│ └─exclude (for mylibrary module)
└─mylibrary (as_submodule)
├─extract_deps.py
└─some_dep (created by extract_deps.py
and should be excluded)
Hope this solved your issue! It definitely helped me out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With