Why is git telling me that the path for my submodule is ignored?
The following path is ignored by one of your .gitignore files:
multi/vim/.vim/bundle/powerline
Use -f if you really want to add it.
Here's what I'm doing:
$ git subaddvim git://github.com/Lokaltog/vim-powerline.git powerline
The following path is ignored by one of your .gitignore files:
multi/vim/.vim/bundle/powerline
Use -f if you really want to add it.
$ git help subaddvim
`git subaddvim' is aliased to `!f(){ [ $# -eq 2 ] && git submodule add $1 multi/vim/.vim/bundle/$2; };f'
Edit: Looks like it's the p
in p
owerline:
$ git subaddvim git://github.com/Lokaltog/vim-powerline.git p
The following path is ignored by one of your .gitignore files:
multi/vim/.vim/bundle/p
Use -f if you really want to add it.
$ git subaddvim git://github.com/Lokaltog/vim-powerline.git owerline
Cloning into 'multi/vim/.vim/bundle/owerline'...
I don't understand why.
Edit 2: I found a file in the submodule clone destination:
multi/vim/.vim/bundle$ cat powerline/.git
gitdir: ../.git/modules/multi/vim/.vim/bundle/powerline
If I remove that and try again, I get a different error:
$ git subaddvim git://github.com/Lokaltog/vim-powerline.git powerline
fatal: Not a git repository: ../.git/modules/multi/vim/.vim/bundle/powerline
Unable to checkout submodule 'multi/vim/.vim/bundle/powerline'
Maybe there's some thing messed up with my .git? (I had cloned this repo yesterday and then reverted that change.)
Edit 3: I tried using git submodule
directly (instead of my alias) and it worked! I can re-create the issue (sometimes) by doing git reset --hard
after the clone. Seems like it's a combination of my alias not working the same as the git command git ignoring the .git
file (or doing something magic that I don't understand). And maybe something to do with my .git/config having a reference to powerline.
Edit 4: My previous edit wasn't clear: Although using git submodule
directly worked. It does not always work. I don't know why it worked in the first place.
I've narrowed it down to a reproducible case. It looks like the issue is caused by git assuming that submodules are in the root directory. Here's my test script.
if [ ! -d remote ] ; then
echo
echo Setup remote test repo
mkdir remote
cd remote
git init
touch firstfile
git add firstfile
git ci -m'first'
cd -
fi
# Pick one of these lines:
submodule=multi/plugin
# OR
submodule=plugin
echo
echo Setup test repo
mkdir test
cd test
git init
touch firstfile
git add firstfile
git ci -m'first'
echo
echo submodule add
git submodule add ../remote $submodule
ls -ld $submodule/.git
cat $submodule/.git
echo
echo submodule remove
git reset --hard HEAD
ls -ld $submodule/.git
cat $submodule/.git
rm -r $submodule/
echo
echo submodule re-add
git submodule add ../remote $submodule
ls -ld $submodule/.git
cat $submodule/.git
Using submodule=multi/plugin
will fail:
submodule re-add
fatal: Not a git repository: ../.git/modules/multi/plugin
Unable to checkout submodule 'multi/plugin'
-rw-r--r-- 1 pydave mkgroup 37 Aug 1 10:08 multi/plugin/.git
gitdir: ../.git/modules/multi/plugin
(After this, if you run git submodule add
, you'll get the "following path is ignored" message.)
But submodule=plugin
will succeed:
submodule re-add
-rw-r--r-- 1 pydave mkgroup 31 Aug 1 10:07 plugin/.git
gitdir: ../.git/modules/plugin
The relative paths are both using ../.git
, which is only correct for the second option -- when the submodule is in the root of the git project.
I've rename this question to be more specific to my problem and re-asked the original question.