2014-02-10 133 views
2

我無法將「taget」目錄添加到「.gitignore」文件。我做壞事:-(我無法將目錄添加到.gitignore

[email protected]:~/git/gitRepo$ tree -L 3 -a 
. 
├── .git 
    ... 
├── .gitignore 
└── MyProject 
    ├── .classpath 
    ├── pom.xml 
    ├── .project 
    ├── .settings 
    ... 
    ├── .springBeans 
    ├── src 
    │   ├── main 
    │   └── test 
    └── target 
       ├── classes 
        ├── m2e-wtp 
       └── test-classes 

269 directories, 32 files 
[email protected]:~/git/gitRepo$ 
[email protected]:~/git/gitRepo$ cat .gitignore 
*.*~ 
*.class 
*.jar 
*.war 
*.ear 
MyProject/.classpath 
MyProject/.project 
MyProject/.settings/ 
MyProject/target/ 
/MyProject/target/ 
target 
[email protected]:~/git/gitRepo$ 
[email protected]:~/git/gitRepo$ git status 
# On branch 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: .gitignore 
# modified: MyProject/.settings/org.eclipse.wst.validation.prefs 
# modified: MyProject/target/classes/log4j.xml 
# modified: MyProject/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF 
# modified: MyProject/target/m2e-wtp/web-resources/META-INF/maven/example.net/gitRepo/pom.properties 
# modified: MyProject/target/m2e-wtp/web-resources/META-INF/maven/example.net/gitRepo/pom.xml 
# 
no changes added to commit (use "git add" and/or "git commit -a") 
[email protected]:~/git/gitRepo$ 

「MyProject的/的.classpath」被忽略列表,但我還是在「混帳地位」 MyProject的/目標*和MyProject的/ .settings看到。 能否請你幫我我做什麼不好? 謝謝!

+0

可能重複(http://stackoverflow.com/questions/1139762/gitignore文件 - 不忽略) – poke

回答

3

1)提交所有改變的代碼。

2)修正的.gitignore

3)的git RM -r --cached。

這將刪除索引中的所有內容。

4)git add。

5)git的承諾-m 「的.gitignore現在工作」

現在,它的工作原理:-)

的[.gitignore文件以不忽略]
2

你需要使用git rm --cached到從索引中刪除的文件。該文件gitignore只適用於尚未被提交的文件。

相關問題