Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git : List all unmerged changes in git

Tags:

git

branch

People also ask

How do you tell if a git branch has been merged?

You can use the git merge-base command to find the latest common commit between the two branches. If that commit is the same as your branch head, then the branch has been completely merged.

Do merged branches get deleted?

The more the branches and master diverge away from each other the farther away their “common ancestor” commit becomes. When you're done with a branch and it has been merged into master, delete it. A new branch can be made off of the most recent commit on the master branch.

What does git branch command do?

The git branch command lets you create, list, rename, and delete branches. It doesn't let you switch between branches or put a forked history back together again. For this reason, git branch is tightly integrated with the git checkout and git merge commands.


To list branches with commits not merged into master:

git branch --no-merged master

To list the relevant commits:

git cherry -v master <branch>

I came across this question when I was trying to remember the syntax of...

git log <branch> --not master --stat

This will show commits to <branch> that have not been merged to master. The --stat will include the files that were changed with the commits. You can also use this to compare any two branches by replacing master with a different branch name.


This question is already well answered, but there is one more answer I think is worth documenting:

List all commits on any branch not already merged with master:

git log --all --not master

or, equivalently:

git log --all ^master

The --all picks up all branches, so you don't have to list them, then --not master or ^master remove master from the selection.