image-fa2f36c7bfa4cbb8afd83ba565b30663198d9bab-5000x3313-jpg

Github Commands with Git Bash

How do I fetch all Git branch?

1. First of all, clone the github file

git clone https://github.com/account-name/file-name.git

2. Enter the file with the command

cd file-name/ 

3. Run this command first only if there is a remote branch on the server that is not tracked by your local branch

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

4. fetch all branches from all remotes like this

git fetch --all

5. Update all local branches tracking remote branches to avoid conflicts, with the command

git pull --all

6. However, this can be still insufficient. It will work only for your local branches which track remote branches. To track all remote branches execute this oneliner BEFORE git pull --all:

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