Reputation: 1948
I need to find the most recently merged branch into master. So I'm using
git branch -r --merged master
But the problem is that it lists the unmerged branches as well.
I run this on a fresh clone of the repository but the unmerged branches still show up. Can someone tell me what might be wrong?
Upvotes: 3
Views: 482
Reputation: 21938
Here the branch you're comparing every branch to is master
, your local version.
You might have an obsolete local ref. To rule it out, you can
git checkout master
git pull
then retry your initial command, and output should be only branches whose tip is in master
's history (or is reachable from master
's tip, if you prefer)
Another cause could have been obsolete refs for the other branches as well, of course, but the above pull
is implying a fetch
so the remote-tracking branches will be ok too.
Note : I assumed you only have master
in local and the branches you're comparing against are remote ones, like -r
suggested. If in the contrary you have local branches, and some show up unexpectedly in the "merged" output, be sure to update their definitions too.
Upvotes: 2