I'm on a branch with some changes. Changing branch is a pain as some files are locked by processes, so to change branch I'd have to stop all the processes which have locks, then stash
the changes before checking out the other branch to see its log.
Is it possible to view the log for a different branch, without having to check it out?
git log <branch>
, where <branch>
stands for the name of the branch of interest?
cherry
and rev-list
.
TL;DR
Use
git log <branch>
where <branch>
is the name of the branch of interest.
From the git-log man-page...
A simplified version of the git-log
synopsis given in that command's man page is
git log [<revision range>]
Further down, you can find the following passage:
When no
In others words, git log
is equivalent to git log HEAD
. If you're on a branch, called mybranch
, say, this command is also equivalent to git log mybranch
.
You want to limit the log to commits reachable from another branch, i.e. a branch you're not currently on. The easiest way to do that is to explicitly pass the name of the branch of interest to git log
:
git log <branchname>
See the gitrevisions manpage for more details about the many forms that the <revision-range>
argument can take.
Success story sharing
master
), whether it be checked out or not, and on a remote branch (e.g.origin/master
).git log mybranch
and it throw an error, but then, when I rungit checkout mybranch; git checkout master; git log mybranch
it worked even without "origin/". That's why I thought that I need to checkout my branch first. But I simply had to use "git log origin/mybranch" in order to look for a history of the remote branch. Thank you.