我遇到了git clean問題,排除了嵌套dirs的選項。Git clean不包括嵌套的子目錄
我想清除所有未提交的文件,不包括vendor/bundle
dir。 我的測試回購loks,如:
debugg-dir/
.git/
file.txt
not-commited-file
not-commited-folder
another-not-commited-file
vendor/
bundle/
another-not-commited-file
重現測試回購有:
git init debugg-dir && cd debugg-dir
touch file.txt && g a . && git ci -m "Commit"
mkdir -p not-commited-folder && touch not-commited-folder/another-not-commited-file
mkdir -p vendor/bundle && touch vendor/bundle/another-not-commited-file && touch not-commited-file
的Git clean命令:
git clean -d -x -n -e vendor/bundle
預計將有清潔後:
debugg-dir/
.git/
file.txt
vendor/
bundle/
another-not-commited-file
是有任何正確的方法來從git clean命令中排除嵌套的目錄?
#編輯:
說明:
沒有針對此情況不 「乾淨」 的解決方案。 Git clean不包括與git clean -d -x -n -e dir_name
dirs,但這不適用於嵌套dirs。 git中的這個bug還是有一些很好的理由呢?更多信息爲什麼這不起作用,你可以找到in source。長話短說,排除模式只適用於字符串,直到模式中的第一個'/'。
我的解決辦法:
cd vendor && git clean -dxf -e bundle && cd ..
git clean -dxf -e vendor
有了這個,我設法只保留嵌套的目錄和它的內容。
'git clean'沒有交互模式。可以? –
它有。試試看(或者閱讀'git clean --help')。免責聲明:在我的筆記本電腦上,'git --version'顯示'git version 1.8。5',它可能不存在於早期版本 – ThanksForAllTheFish
看不見[這裏](https://www.kernel.org/pub/software/scm/git/docs/git-clean.html),但更多官方的[這裏](http://git-scm.com/docs/git-clean)確實有'-i'開關。 –