I would like to know how to automatically clone all the remote's arms to the location, without having to do the command below for each one.
git checkout -b <branch> <remote>/<branch>
There are many arms to be able to do this one by one.
I would like to know how to automatically clone all the remote's arms to the location, without having to do the command below for each one.
git checkout -b <branch> <remote>/<branch>
There are many arms to be able to do this one by one.
I suggest creating the alias below, which performs the checkout for all the remote branches. The name of each branch in place will be the same as the remote branch.
git config --global alias.clone-branches '! git branch -a | sed -n "/\/HEAD /d; /\/master$/d; /remotes/p;" | xargs -L1 git checkout -t'
Created the alias, just run it like this:
git clone-branches
Another way to run would be by using the git ls-remote
This command lists the references of the remote repository, for example:
git ls-remote --heads origin
The return will be the list of remots in the current repository.
Using a simple command line in Powershell you can download the branches:
git ls-remote --heads origin | % { $_ -match 'refs/heads/(.*)' | out-null; $matches[1] } | % { git checkout $_ }
If you want to know the details, read the post .
git clone <repo>
and then a git fetch origin
(or any name you've given). So your location has all branchs from the remote.