2013-04-12 174 views
0

我使用git 1.7.9.5,並且我有一個目錄_hashdist,其中沒有跟蹤文件。這是我的.gitignoregit clean -dfx不會刪除被忽略的目錄

*~ 
*.pyc 
*.pyo 

/opt 
/bld 
/db 
/src 
/_hashdist 
/local 

因此將其忽略,如圖:

$ git status --ignored 
# On branch master 
# Ignored files: 
# (use "git add -f <file>..." to include in what will be committed) 
# 
# _hashdist/ 
nothing to commit (working directory clean) 

然後我想通過將其刪除:

$ git clean -dfx 
Removing _hashdist/ 

它正確地說,這是刪除它。但沒有實際發生:

$ git status --ignored 
# On branch master 
# Ignored files: 
# (use "git add -f <file>..." to include in what will be committed) 
# 
# _hashdist/ 
nothing to commit (working directory clean) 

$ ls -d _hashdist/ 
_hashdist/ 

的目錄仍然存在。這對我來說非常困難,因爲我一直使用git clean -dfx來清理所有內容,而這是第一次不起作用。

+0

是的,git應刪除該目錄,但顯然無法這樣做。用'rm -rf _hashdist'手動刪除工作嗎? – michas

+0

是的,手動刪除目錄工作正常(這是我一直在做的事情,這只是令人討厭)。 –

回答

1

嘗試使用strace找出發生了什麼事。

你應該看到:

$ strace git clean -dfx 
[...] 
unlink("_hashdist/foo")     = 0 
getdents(3, /* 0 entries */, 32768)  = 0 
close(3)        = 0 
rmdir("_hashdist/")      = 0 
[...] 

還有就是unlink調用刪除文件和rmdir調用刪除該目錄。 這兩個都是成功的= 0在我的情況。

也許這可能會帶來一些亮點。

如果rmdir成功,但目錄仍然存在,唯一的想法是我能想到的是另一個過程,它會重新創建該目錄。 - 但手動刪除目錄時,這應該是相同的...