Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list branches that contain a given commit on a specific repository?

So I've read Git: How to find out on which branch tag is? and many other posts and I already know how to use: git branch --contains tag

However, I still need to know how to list branches that contain a given commit (or tag) in specific repository.

Background

I've extracted a list of tags from a remote repository archive using:

git ls-remote --tags archive

Now, for each of the tags extracted, I wish to get the list of containing branches. Using command: git branch --contains tag doesn't help because the tags are not found because they do not exists in origin repository.

like image 744
idanshmu Avatar asked Jan 26 '16 07:01

idanshmu


1 Answers

You need to git branch--all--containscommit to see branches from other remotes.

This still depends on you fetching the commits you want to examine from whatever remote they're on - git fetch archive in your case.

Without it your local repository doesn't have the commits, and pretty much nothing will work. For example, you can't git log etc. without having the commits present. There are all sorts of (semi-working) workarounds, like SSHing to the server and working on it (if it's available) or using all sorts of web APIs (GitHub, Stash) if they're available, but basically you need to the the commits present. git ls-remote is the exception that can work on a remote repository without having anything locally.

like image 78
conio Avatar answered Nov 12 '22 02:11

conio