2015-08-18 40 views
4

我的.gitignore文件有什麼問題?我的gitignore有什麼問題?

build/ 
/build 
/*/build/ 
/*/*/build/ 
build/ 

這是我的目錄結構:

myroot 
    FacebookSDK 
     +--src 
     +--build 
      +--foo 
      +-- bar 
    app 
     +--scr 
     +--build   
    build 
     +--other stuff... 
     +--other stuff.. 
    .gitignore 
    other stuff... 

的問題是,FOO酒吧沒有忽視!

可能是什麼回事?

xxxxs-my:xxxx xxx$ git status 
On branch master 
Your branch is up-to-date with 'origin/master'. 
Changes not staged for commit: 
(use "git add <file>..." to update what will be committed) 
(use "git checkout -- <file>..." to discard changes in working directory) 

modified: FacebookSDK/FacebookSDK.iml 
modified: FacebookSDK/build.gradle 
modified: FacebookSDK/build/intermediates/bundles/debug/classes.jar 
modified:  FacebookSDK/build/intermediates/bundles/debug/res/drawable/com_facebook_button_blue.xml 
+0

你已經提交這些目錄嗎?如果你這樣做了,你必須刪除你的GIT的「構建」存儲庫,在「構建」和其他子文件夾將被正確忽略後 – Matthieu

回答

4

你應該只需要這條規則,per the documentation

**/build 

這將在全球範圍排除build文件夾。

如果之前已添加這些文件夾中的任何一個,則必須通過git rm將其從Git中刪除。

有什麼實際錯誤是你.gitignore

  • /buildbuild/是等價的;他們將匹配頂級build/文件夾。
  • /*/build/*/*/build不會匹配任何東西。
+0

我不知道,相同的結果: - ((((( –

+0

你確定這些文件以前沒有添加到Git之前?如果你做了一個'git status && git add .',它是否仍然選擇它們? – Makoto

+0

他們仍然被挑選.... –

0

我相信這是因爲三貴忽略線路是從根目錄:

/build 
/*/build/ 
/*/*/build/ 

時,他們應該是從當前目錄:

./build 
./*/build/ 
./*/*/build/ 
+0

它來自Git文件夾的上下文。記住:Git不關心任何不在其追蹤器中的東西。 – Makoto

+0

啊,我明白了。如果她只是'*/build /'而不是任何向前開始的前斜線,它會不起作用嗎? – nicholaschiasson

0

嘗試使用

build/ 
**/build/ 

i n .gitignore

如果文件已被跟蹤,請使用git rm --cached myfile將其從版本控制中刪除,但將它們保留在本地存儲庫中。一旦從版本控制中刪除,它們就不應該在更改時被檢測到。

+0

謝謝,不起作用...: - (((( –

+0

我已編輯我的答案。 –