> For the complete documentation index, see [llms.txt](https://blog.log4think.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.log4think.com/find-commit-in-branch.md).

# 2010-08-18  Git中判断一个commit是否在某个branch中

方法1：`git branch --contains commit`

方法2：查找reflog `git reflog show --all | grep a871742`

会有类似如下的结果：`a871742 refs/heads/completion@{0}: commit (amend): mpc-completion: total rewrite`，其中 completion 就是所在的 branch

注：`git reflog show`等价于`git log -g --abbrev-commit --pretty=oneline`
