5

Can someone explain/provide an example of how to list branches that contains another branch in git?

can I use the contain attribute?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Jiraiya
  • 61
  • 6

2 Answers2

8

A branch name is just a fancy pointer to a given commit (in other words, it's a commitish), so you can look for branches that contain it with the --contains option:

$ git branch --contains my_branch

And if you want to check remote branches as well, you can add the -r flag:

$ git branch -r --contains my_branch
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • *refspec* is the wrong technical word, as it means `[+][:[]]` in Git. Maybe you wanted *reference* here? – torek Sep 21 '18 at 19:00
  • @torek yup, you're right. Lapsed concentration there for a moment. I meant to say commitish. – Mureinik Sep 21 '18 at 19:33
1

Sounds like you want to know about git branch --contains whatever-branch. Use -r if you want to check remote branches as well.

eftshift0
  • 26,375
  • 3
  • 36
  • 60