6

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

can I use the contain attribute?

2
  • Are you looking for branches that contain a specific branch, or "any branch that contains any other branch"? Commented Sep 21, 2018 at 14:52
  • 1
    branches that contain a specific branch, thx Commented Sep 21, 2018 at 14:53

2 Answers 2

9

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
Sign up to request clarification or add additional context in comments.

2 Comments

refspec is the wrong technical word, as it means [+]<name>[:[<name>]] in Git. Maybe you wanted reference here?
@torek yup, you're right. Lapsed concentration there for a moment. I meant to say commitish.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.