Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I print the log for a branch other than the current one?

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?

like image 991
BanksySan Avatar asked Jul 12 '15 13:07

BanksySan


People also ask

Does git log show all branches?

Graph all git branchesDevelopers can see all branches in the graph with the –all switch. Also, in most situations, the –decorate switch will provide all the supplemental information in a formatted and nicely color-coded way.

How do I fetch a different branch?

just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.

How do you view all activity in the current branch?

To see local branches, use the git branch command. The git branch command lets you see a list of all the branches stored in your local version of a repository.


1 Answers

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 <revision range> is specified, it defaults to HEAD (i.e. the whole history leading to the current commit)

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.

like image 91
jub0bs Avatar answered Sep 18 '22 19:09

jub0bs