4

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 

3 Answers 3

4

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

git pull --all 
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks much..didn't know it before!
git pull just passes --all to git fetch, where it means "fetch from all remotes". In the OP's situation (where there is just one remote), this has no effect.
@torek If there is one remote but Git has been configured not to use that by default, --all does have an effect: it is equivalent to specifying that one remote for fetching. But pull does do extra unnecessary work here, and fetch might as well have been called directly.
@hvd: ah, now that (one remote, configured out by default) is a sneaky corner case I had not considered!
1

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

Comments

0

git ls-remote can list references in a remote repository. You may need -h and use grep to filter the output.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.