Skip to content

Instantly share code, notes, and snippets.

@mrmorris
Created April 28, 2020 11:48
Show Gist options
  • Save mrmorris/dffa1abc1b714a1e50238ab10f5cbd3d to your computer and use it in GitHub Desktop.
Save mrmorris/dffa1abc1b714a1e50238ab10f5cbd3d to your computer and use it in GitHub Desktop.
Git power commands

Is this commit in this branch?

Or, which branch has my commit?

# Any branch have this commit?
git branch --contains $COMMIT_ID

# Filter for branches (only this branch) if it has this commit
git branch $(git symbolic-ref --short HEAD) --contains $COMMIT_ID

# Is this commit in my history?
git merge-base --is-ancestor $COMMIT_ID HEAD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment