yuanrui / blog

Some notes.
http://yuanrui.github.io
3 stars 0 forks source link

Git克隆所有远程分支到本地 #42

Open yuanrui opened 2 years ago

yuanrui commented 2 years ago

Git克隆所有TFS远程分支到本地,在git bash执行以下命令。 先将代码克隆到本地

git clone ssh://tfs-server75:22/tfs/XXXProject/_git/WorkCode

使用cd命令切换到"WorkCode"目录,然后执行以下命令

git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all

查看本地分支情况

git branch

查看远程分支情况

git branch -r

切换分支

git checkout xxxx_branch

参考链接:https://stackoverflow.com/questions/10312521/how-do-i-fetch-all-git-branches