git pull push 所有分支

  • 因为远端 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 上去。

原文地址:https://www.cnblogs.com/chenfulin5/p/10973581.html