2010-09-23 104 views
1

在.gitignore中使用子目錄條目時,「git clean -X」不會清除被忽略的子目錄。當.gitignore具有子目錄條目時,git clean -X行爲

$ git init test 
Initialized empty Git repository in /home/jpgariep/git/test/.git/ 
$ cd test/ 
$ mkdir -p a/b/c 
$ touch a/b/c/test 
$ echo '/a/b/' > .gitignore 
$ git add .gitignore 
$ git commit -m "Added .gitignore." 
[master (root-commit) 94e2825] Added .gitignore. 
1 files changed, 1 insertions(+), 0 deletions(-) 
create mode 100644 .gitignore 
$ git status 
# On branch master 
nothing to commit (working directory clean) 
$ git clean -X -d -f 
$ ls a 
b 

爲什麼b仍然存在?

Git版本:1.7.2.3

注意:這還張貼git的郵件列表上2個月前沒有答案。

+0

我在這裏失去了一些東西......你問混帳忽略/ A/B,你是surpirised它忽略/ A/B?我的解釋是否正確,或者我錯過了一個瑣碎的事情? – 2010-09-23 14:31:32

+0

忽略工作正常。問題在於「git clean -X」命令​​。 git clean的-X選項應該用於清除被忽略的文件。 「git clean -X -d -f」應該起到「乾淨」的作用。 – gawi 2010-09-23 15:29:44

+0

'git clean -x -d -f'正常。但我知道你想保留一個目錄,但沒有提交。它看起來像一個錯誤。解決方法是在本地分支上提交所有內容並使用小型x進行清理 – 2010-09-23 21:03:43

回答

相關問題