2014-09-01 164 views
0

我試圖刪除遞歸的文件擴展名,但它保持失敗,無論我試圖。感謝您的任何想法。Git - 遞歸刪除文件擴展名

[email protected]:~/hh/hh_sdk/src/uboot_hh$ git rm -r --cached \*.o 
fatal: pathspec 'src/uboot_hh/*.o' did not match any files 
[email protected]:~/hh/hh_sdk/src/uboot_hh$ sudo git rm -r --cached \*.o 
fatal: pathspec 'src/uboot_hh/*.o' did not match any files 
[email protected]:~/hh/hh_sdk/src/uboot_hh$ sudo git rm -r --cached *.o 
fatal: pathspec 'src/uboot_hh/*.o' did not match any files 
[email protected]:~/hh/hh_sdk/src/uboot_hh$ sudo find . -name *.o -exec git rm -r --cached {} \; 
fatal: pathspec 'src/uboot_hh/lib_arm/_divsi3.o' did not match any files 
fatal: pathspec 'src/uboot_hh/lib_arm/cache.o' did not match any files 
fatal: pathspec 'src/uboot_hh/lib_arm/_udivsi3.o' did not match any files 
fatal: pathspec 'src/uboot_hh/lib_arm/_umodsi3.o' did not match any files 
+0

是任何你'.o'文件通過實際的Git跟蹤? – 2014-09-01 08:29:22

回答

1

find方法應該工作得很好,但你需要單引號的'*.o'模式,因爲外殼,否則將它傳遞給find之前擴大*

還需要將--force選項(-f)傳遞給git rm如果文件不存在於文件系統中存在了:

find -name '*.o' -exec git rm -f -r --cached {} \; 
+0

謝謝,我完全按照你的寫法來嘗試,但是我仍然感到致命:pathspec'src/linux/linux-04.02.00.07/mm/vmalloc.o'與任何文件都不匹配 fatal:pathspec'src/linux/linux -04.02.00.07/mm/madvise.o'沒有匹配任何文件 ...... 而且我仍然在git gui中看到這些文件「作爲未知變化 – ransh 2014-09-01 15:46:57

+0

輸出是什麼:'find -name'* .o'-exec bash -c'file = {}; echo「$ file」; git rm -f -r --cached「$ file」;' \;'? – hek2mgl 2014-09-01 15:52:59

+0

嗨,它仍然是一樣的 – ransh 2014-09-01 18:41:22