By default, git copies all your remote branches whenever you clone, fetch, or pull your remote repository. You can view all your branches using git branch -a command.
Clone, pull or fetch from a remote repository:
1 2 3 4 5 6 |
# if remote not added git clone #or if remote already added git fetch #or if remote already added git pull |
List all git branches including remote:
1 2 3 4 5 6 7 |
## get all branch names git branch -a ## * main ## remotes/origin/HEAD -> origin/main ## remotes/origin/bugfix1 ## remotes/origin/feature1 ## remotes/origin/main |
Switch/checkout to a remote branch in local git repository:
1 2 3 |
## git checkout -b ## for example if you want to checkout to feature1 remote branch git checkout -b feature origin/feature1 |