Git 分支


https://blog.csdn.net/wu1169668869/article/details/83345633

git 从远程仓库获取所有分支

git clone xxx

git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done git fetch --all git pull --all

来自Stackoverflow 链接:http://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches

From: 
Snapshot-Content-Location: https://gist.github.com/tstone2077/8380f7862b00b6234963
Subject: Clones as usual but creates local tracking branches for all remote branches.
Date: Sat, 30 Nov 2019 14:34:33 -0000
MIME-Version: 1.0
Content-Type: multipart/related;
	type="text/html";
	boundary="----MultipartBoundary--xhsuDgSyg5rHrd1UYdOmhaiDzplzjrgYJD9AWLqHaA----"


------MultipartBoundary--xhsuDgSyg5rHrd1UYdOmhaiDzplzjrgYJD9AWLqHaA----
Content-Type: text/html
Content-ID: 
Content-Transfer-Encoding: quoted-printable
Content-Location: https://gist.github.com/tstone2077/8380f7862b00b6234963


   =20
  
  
  
  
  
  
  



  
 =20
    
   =20
   =20
   =20
   =20


  
 =20
  Clones as usual but creates local tracking branches for all remote=
 branches.
    
    
  
  

    
    

  
  
  

    


 =20

  

      
    
    

    

/" data-p=
jax-transient=3D"true">




  





    

  
  
  


      
    

      

      

    

  
 =20

      

  




  

  

  
  





  

  


  

  
   =20

   =E9=99=90=E5=88=B6=
=E8=A7=A3=E9=99=A4 

  
=20
=20 =20

3D"@tstone2077" tstone2077/git-cloneall
Last active 2 years ago =E2=80=A2 Report abuse

  • <= /path>
    =20 =20 =20 =20
  • =20 7
    =20 7
  • 6
Embed
What would you like to do?
</script>" ar= ia-label=3D"Clone this repository at <script src=3D"https://gist.githu= b.com/tstone2077/8380f7862b00b6234963.js"></script>" readonly=3D"">
<= /clipboard-copy>
=20
Clones as usual but creates local tracking branches for all remote bran= ches.
=20
#!/bin/bash= # Clones as= usual but creates local tracking branches for all remote branches.<= /td> # To use, c= opy this file into the same directory your git binaries are (git, git-flow,= git-subtree, etc) clone_output=3D$= ((git clone "$@" ) 2>&1) retval=3D$? echo $clone_outp= ut if [[ $retval !=3D 0 ]] ; then exit 1 fi pushd $(echo $c= lone_output | grep 'Cloning into' | head -1 | sed 's/Cloning into .\(.*\).\.\.\..*/\1= /') > /dev/null 2>&1 this_branch=3D$(git branch | sed 's/^.= .//') for i in $(git branch -r | grep -v HEA= D); do branch=3D$(echo $i | perl -pe 's/^.*?\///') # this doesn't have to be done for e= ach branch, but that's how I did it. remote=3D$(echo $i | sed 's/\/.*//') if [[ "$this_= branch" !=3D "$branch" ]]; then= git branch -t $branch $remote/$branch fi done popd > /dev/null 2>&1
=20
=20
3D"@AnneTheAgile"
=20
=20 =20

This comment has been minimized.

<= /path>Show comment
Hide comment
=20
=20
Copy link
Report content =20
=20 =20 =20 =20

=20 AnneTheAgile =20 commented on 17 Dec 2014

3D"@marklove5102"
=20
" data-ga-click=3D"Markdown Toolb= ar, click, bold" role=3D"button" hotkey=3D"b"> " data-ga-click=3D"Markdown T= oolbar, click, italic" role=3D"button" hotkey=3D"i">
" data-ga-click= =3D"Markdown Toolbar, click, link" role=3D"button" hotkey=3D"k">
=20