Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT - How to get all newly created branches

Tags:

git

git-branch

I have below situation, which I am not getting a solution to.

Say I have cloned a project to my local system. Now, in the project if I do git branch -a, it lists me say 3 remote branches along with local branches.

Now, after a day, say 10 different developers, pushed 10 different branches to the remote repo. Now, if I do a git branch -a, it still shows me 3 remote branches.

One solution is to ask each developers to give the name of the branches and I can run the command git pull origin newBrn1. I have to run this 10 times with the names accordingly.

Isn't there a command which gives me the list that would include the newly created branches in one go?

I tried running git pull, but throws an error stating:

You asked me to pull without telling me which branch you want to merge with
like image 760
tdka Avatar asked Oct 20 '25 04:10

tdka


2 Answers

You can use --all option to tell that you want to pull all branches:

git pull --all
like image 152
Zbynek Vyskovsky - kvr000 Avatar answered Oct 21 '25 23:10

Zbynek Vyskovsky - kvr000


Fetching the branches from remote will help you. It will sync all the remote tracking branches in your local repository with remote repository. And its console output will let you know about the branches that have been newly created on the remote repository. Here is the command:

git fetch

Read more about fetch here: https://git-scm.com/docs/git-fetch

like image 31
Manish Avatar answered Oct 22 '25 00:10

Manish