Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.git/info/exclude replacement for git submodule?

Tags:

git

gitignore

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.

like image 969
4ntoine Avatar asked Oct 07 '16 07:10

4ntoine


People also ask

Should you Gitignore submodules?

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.

Where is git info exclude?

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.


1 Answers

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.

like image 185
NiklasMH Avatar answered Sep 20 '22 06:09

NiklasMH