1. 程式人生 > >刪除隱性的git submodule

刪除隱性的git submodule

刪除隱性的git submodule

(金慶的專欄 2018.8)

正常的submodule會在 .gitmodule 檔案中,TortoiseGit 會有 Submodule Update 選單。
還有一種隱性的 submodule, .gitmodule 檔案中看不到它,無法 update.
golang開發中的vendor目錄下經常會不小心新增一個帶 .git 的目錄,就變成了一個假的submodule.
用 Repo-browser 看這個目錄是個submodule連結, clone 出來就只有一個空目錄。

刪除這個submodule不能用 git delete, 提交時會報錯:

git.exe add -f [...]

fatal: pathspec 'src/vendor/github.com/grpc-ecosystem/grpc-opentracing' did not match any files

git did not exit cleanly (exit code 128)

git delete 父目錄也無法提交。

但是可以直接刪除(不用git delete), 然後提交併Push. 好像只有這個辦法。