爲什麼git告訴我我的子模塊的路徑被忽略?爲什麼git告訴我我刪除的子模塊會被忽略?
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 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'
編輯:看起來像它的p
在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'...
我不明白爲什麼。
編輯2:我發現輔助模塊克隆目的地的文件:
multi/vim/.vim/bundle$ cat powerline/.git
gitdir: ../.git/modules/multi/vim/.vim/bundle/powerline
如果我刪除,然後再試一次,我得到一個不同的錯誤:
$ 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'
也許有一些東西搞砸了我的.git? (我昨天克隆這種回購和再恢復這種變化。)
編輯3:我想直接使用git submodule
(而不是我的別名)和它的工作!我可以通過在克隆後執行git reset --hard
來重新創建問題(有時)。似乎它是我的別名的組合,不像git命令一樣忽略.git
文件(或者做一些我不明白的魔法)。也可能與我的.git/config有關powerline的參考有關。
編輯4:我以前的編輯不清楚:雖然使用git submodule
直接工作。它並不總是有效。我不知道它爲什麼起作用。
我已經縮小到一個可重複的情況。看起來問題是由git引起的,假設子模塊位於根目錄中。這是我的測試腳本。
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
使用submodule=multi/plugin
將失敗:(。在此之後,如果運行git submodule add
,你會得到 「下面的路徑將被忽略」 消息)
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
但submodule=plugin
會成功:
submodule re-add
-rw-r--r-- 1 pydave mkgroup 31 Aug 1 10:07 plugin/.git
gitdir: ../.git/modules/plugin
相對路徑都是我們../.git
,這隻適用於第二個選項 - 當子模塊位於git項目的根目錄時。
我已經將此問題重命名爲更具體到我的問題和re-asked the original question。
你有一個全局排除文件? 'git config -l |是什麼? grep排除'說? – 2012-07-31 21:52:46
@JonLin:'core.excludesfile =〜/ .gitignore'但是這個文件沒有什麼奇怪的。我嘗試評論所有行,並且我有同樣的錯誤。 – idbrii 2012-07-31 22:01:04
'.git/info/exclude'中的任何內容? – Christopher 2012-08-01 02:37:11