Make Branch accessible after git fetch

83 views Asked by At

Is there a way to make a branch directly accessible after a git fetch without git checkout <newbranch>?

If I use the git fetch command I want to see the new branches directly in the list shown after I use e.g. git branch.

1

There are 1 answers

0
PeterSW On BEST ANSWER

If by "accessible" you mean visible in the list given by git branch then you can use the -a flag:

git branch -a

it will show all the branches including the remote tracking ones.

So if someone added second_branch to the remote repository, before running git fetch you might see:

%> git branch -a
* master
remotes/origin/master

Then after the git fetch you might see:

%> git branch -a
* master
remotes/origin/master
remotes/origin/second_branch

If you only want to see the remote tracking branches there's also the -r option.