Git: get the list of branches into which current branch was ever merged
Maybe each developer faced that uncomfortable moment when you don’t remember whether you’ve merged you story code. So you looking for that code and find it’s in
my-feature branch. But you still don’t remember whether you merged it or not.
Question: How to get a list of branches into which
my-feature was merged?
- How to cleanup Mercurial repository?
- How to merge two branches in Mercurial when there is nothing to merge
- How can I tell git which vim to use?
- Configuring VisualSVN Server to use _svn instead of .svn
- Why do I see a deleted remote branch?
- GIT Removing FETCH refs from remote tracking
One Solution collect form web for “Git: get the list of branches into which current branch was ever merged”
Have you tried the following command?
git branch -a --merged my-feature
It will print a list of all branches (local or remote) whose tips are reachable from (i.e. ancestors of) the tip of
my-feature. If you’re only interested in local branches only, you can want drop the
As an example, if your repository looks as follows
A -- B [branch1] \ C -- D -- E [origin/HEAD=origin/branch2] \ \ \ H -- I [HEAD=branch4] \ F -- G [branch3]
git branch -a --merged branch4
* branch4 remotes/origin/HEAD -> origin/branch2 remotes/origin/branch2 branch1
branch4is trivially reachable from itself.
remotes/origin/branch2? Because they both point (indirectly and directly, respectively) to commit
E, which is an ancestor of
branch4‘s tip, commit
branch1? Because it points to commit
B, which is an ancestor of commit
- Why not
branch3? Because it points to commit
G, which is not an ancestor of commit