我正在使用 ubuntu 12.04 TLS,其中我在特定目錄中有一個 git 存儲庫,我嘗試的是獲取存儲庫的計劃備份並將其放置在可以郵寄的特定目錄中。
在這個過程中,我開始知道透過谷歌搜尋找到特定目錄中的所有 git 儲存庫,我在下面的命令中找到了這個
find /home/mysys/D/ -name .git -type d -prune
但它所包含的路徑為
/home/mysys/D/testing/.git
其中列出了目錄中關聯的所有 git 檔案並且它正在工作,但是我需要執行 git bundle create directoryname.bundle --all 以使其更加自動化,其中我嘗試了以下操作
find /home/mysys/D/ -name .git -type d -prune -exec git bundle create test.bundle --all {} \;
上面的 bash 腳本返回
fatal: Invalid gitfile format: .git
如何做到這一點才能使其工作穩健。
提前致謝。
答案1
你想成為在git bundle
執行時git控制的目錄,所以使用find ... -execdir ... \;
find /home/mysys/D/ -type d -name .git -prune -execdir git bundle create backup.bundle --all \;
這將在所有這些目錄中建立一個 backup.bundle。從那裡您可以移動它們,或使用更多腳本來處理它們。但事情的捆綁方面已經得到處理。