I have an old branch, which I would like to delete. However, before doing so, I want to check that all commits made to this branch were at some point merged into some other branch. Thus, I'd like to see all commits made to my current branch which have not been applied to any other branch [or, if this is not possible without some scripting, how does one see all commits in one branch which have not been applied to another given branch?].
Git rev-list will list commits in one branch that are not in another branch. It is a great tool when you're trying to figure out if code has been merged into a branch or not. Using the --oneline option will display the title of each commit.
In order to see the commit differences between two branches, use the “git log” command and specify the branches that you want to compare. Note that this command won't show you the actual file differences between the two branches but only the commits.
To confirm, you can run git branch . The branch that you are on will be the one with a * next to it. Git checkout might fail with an error message, e.g. if it would overwrite modified files. Git branch should show you the current branch and git log master allows you to view commit logs without changing the branch.
To see a list of which commits are on one branch but not another, use git log:
git log --no-merges oldbranch ^newbranch
...that is, show commit logs for all commits on oldbranch that are not on newbranch. You can list multiple branches to include and exclude, e.g.
git log --no-merges oldbranch1 oldbranch2 ^newbranch1 ^newbranch2
Note: on Windows command prompt (not Powershell) ^
is an escape key, so it needs to be escaped with another ^
:
git log --no-merges oldbranch ^^newbranch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With