git之復合指令和submodule
1.
別名設置在路徑C:\Program files\Git\etc\profile.d\aliases.sh里面
通過alias設置了一個復合指令 alias gsync='date;git pull m master;git add .;git commit -m "sync-desk"; git push m master'
修改后在git bash里面運行 source 'C:\Program files\Git\etc\profile.d\aliases.sh' 生效
2.
在git倉庫中有submodule,但是不知從什么時候開始,在一臺機器上gsync后,在另一臺機器gsync第一次總是出現 ![rejected],第二次gsync后成功了,然后第一臺機器啥都沒干再次gsync會發現submodule目錄會有 2 +-,同時git status發現submodule的目錄顯示 modified。
解決方法:
參考 https://git-scm.com/book/fa/v2/Git-Tools-Submodules
在上述第一臺機器顯示modified的狀態下,運行
git checkout --recurse-submodules
git submodule update --init --recursive
兩條命令后,git status發現變為干凈的了,之后兩臺隨意 gsync不會有問題了
---2024.5.27, 又一次不起作用了,根據 https://stackoverflow.com/questions/58309538/what-does-upload-pack-not-our-ref-mean-when-fetching-git-refs-via-tags 解決
在發生reject 的機器上,執行
git submodule deinit -f dashboard (最后是submodule名字)
git submodule summary
git pull --prune --recurse-submodules --force
解決
3.
在一臺機器上 add submodule xxx 后,會發生
(1)在倉庫中創建xxx目錄。
(2)在.gitmodules里面增加entry。
(3)在.git/modules中創建目錄
(4)在(1)的xxx目錄里運行git remote -vv可以看見子模塊路徑。
然后,這時候同步到中心倉庫,再在另一臺機器上同步過來后,上述的(3)和(4)不會生效,需要在另一臺機器重新add submodule,方式
(1) 刪除目錄xxx, rm -rf xxx
(2) git刪除, git rm -rf xxx
(3)添加子模塊,git submodule add xxxx.git
添加后拉代碼
git submodule init
git submodule update
4. "no url found for submodule path in .gitmodules"
錯誤添加了一個sumbodule,刪除后,git update 會報這個錯,是因為刪除的操作沒有add 看 git status 是有一個new file 記錄和一個delete 記錄,git add .后就干凈了,就可以update了
posted on 2023-10-25 17:03 longbigfish 閱讀(53) 評論(0) 收藏 舉報
浙公網安備 33010602011771號