2012-07-31 68 views
-2

爲什麼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' 

編輯:看起來像它的pp 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

+0

你有一個全局排除文件? 'git config -l |是什麼? grep排除'說? – 2012-07-31 21:52:46

+0

@JonLin:'core.excludesfile =〜/ .gitignore'但是這個文件沒有什麼奇怪的。我嘗試評論所有行,並且我有同樣的錯誤。 – idbrii 2012-07-31 22:01:04

+0

'.git/info/exclude'中的任何內容? – Christopher 2012-08-01 02:37:11

回答

1

我認爲答案是在使用不在頂層目錄中的子模塊時,git中存在一個錯誤。

的解決方法是刪除存儲在.git/modules爲輔助模塊中的混帳回購協議:

$ rm -fr multi/plugin/ .git/modules/multi/plugin/ 
$ git submodule add ../remote multi/plugin 
Cloning into 'multi/plugin'... 
done. 
0

因爲這個原因,我會遠離git別名,並依靠bash歷史來記住您之前輸入的內容。你可以回憶起CTRL-R和其他bash命令行善的複雜單線程。看到你在做什麼有助於保持意識到別名會隱藏什麼。走到另一臺機器,你有一個問題,因爲你忘了你的別名究竟是什麼!

+0

通常情況是這樣,但僅適用於每次使用相同文本的命令。我的命令只包含相同的段,並且編輯它們以匹配很麻煩,並且只要寫入整個命令即可。 – idbrii 2012-08-01 15:59:37

相關問題