-
因為遠端 git 服務器上有很多分支,一個個分支pull太麻煩,所以找了 pull 所有分支的方法,如下:
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done git fetch --all git pull --all
-
上面的操作是建立在已經配置了 ssh key 的基礎上。
-
生成 ssh key 命令如下:
ssh-keygen -t rsa -C “xxx.com”
-
先 clone 遠端, 通過git協議 clone
-
這樣 git remote 會自動配置遠端地址
-
然后就可以執行上面的 git pull --all 操作。
-
git push xxx.com --all 能將所有分支push 上去。