

If you’re brave, you could use a combination of the git rev-parse and git rev-list to find if a commit is in the history of a given branch or not. If you are sure you want to delete it, run 'git branch -D docs'. In this case, our docs branch is not fully merged into our master branch: The former will tell you what branches have that treeish merged in, while the latter will do the opposite.
#Git log grep how to#
Perhaps you’ve got a commit SHA from a patch you thought you had applied, or you just want to check if commit for your favorite open source project that reduces memory usage by 75% is in yet.Ĭommit d590f2ac0635ec0053c4a7377bd929943d475297įrom these results we can see that commit d590f2 has been merged into the tests and master branch.īack to the original conundrum: how to figure out if a branch has been merged in! The -merged and -no-merged flags can do just this for you. The -contains tag will figure out if a certain commit has been brought in yet into your branch. The git branch command has a few flags that will help out with this problem. So, how would you find out if a given branch (or commit) is merged into your current branch without having to try and delete it? This is one of the many ways that Git tries really hard not to lose your data for you. Since the branch you’re currently on doesn’t have the branch you want to delete merged in. If you are sure you want to delete it, run 'git branch -D docs'

Ever seen this message when trying to delete a branch?Įrror: The branch 'docs' is not an ancestor of your current HEAD.
