Nickool Nickool - 1 month ago 8
Git Question

how to show remote branches of a specific remote

I have three repositories with different names under one folder:

remote1/branch1
remote1/branch2
remote2/branch1
remote3/branch1


When I want to get the remote branches, I want to do specific remote branches from just one of the repositories, I know that
git branch -r
shows me all of them but I am wondering how to do git branch -r on only one mentioned repository?

I was trying
git branch -r=rep1
or
git branch --remotes=rep1


However this is not correct, wondering if there is a way to do it?

I have only one directory, inside that directory I have different remote
repositories.

here is more information:

$ git remote -v
remote1 https://url/rep1.git (fetch)
remote1 https://url/rep1.git (push)
remote2 https://url/rep2.git (fetch)
remote2 https://url/rep2.git (push)
remote3 https://url/rep3.git (fetch)
remote3 https://url/rep3.git (push)

Answer Source

One quick approach could be to use grep after your git command like this:

git branch --remote | grep rep2