Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7972487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:52:49+00:00 2026-06-04T07:52:49+00:00

git branch -a –contains <hash> gives me all those branches containing hash . what

  • 0

git branch -a --contains <hash> gives me all those branches containing hash. what I want is git branch -a --no-contains <hash>. Unfortunately, there doesn’t seem to be a command to accomplish this, so I’m thinking the solution is something like:

git branch -a | grep -v output of(git branch -a --contains) but my bash isn’t up to the task.

Show all branches that commit A is on and commit B is not on? would seem to apply, but the approach seems more complicated than necessary.

What is the best/most simple approach to accomplish the above?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:52:50+00:00Added an answer on June 4, 2026 at 7:52 am

    grep has a -F option which matches fixed strings. Would be useful for what you’re doing.

    git branch -a | grep -vF "$(git branch -a --contains <hash>)"
    

    Unfortunately, -F will filter out branches names that have a partial match. As suggested by antak, we can use comm instead for a more reliable diff.

    git branch -a | sort | comm -3 - <(git branch -a --contains <hash> | sort)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cloned a Git repository containing many branches. However, git branch only shows one:
Is there a Git command equivalent to: git branch | awk '/\*/ { print
Right now, when I type git branch it lists my branches in an arbitrary
I've tried git branch -r , but that only lists remote branches that I've
I want to create a git branch that will work independent of the master
The command git branch -a lists a bunch of branches that are NOT on
How can you merge two branches in git, retaining necessary files from a branch?
When I type git branch , I receive a list of branches that appear
git version 1.7.3.5 I have the following branches: git branch image master * video
I know I can do git branch --all , and that shows me both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.