kofucii
kofucii

Reputation: 7653

How to examine Git commits from another branch?

I want to view one particullar commit from another branch without switching to it. With gitk I cannot see the tree of the other branch. I don't want to push to Gerrit for instance and examine it there. The problem is that the only way to see it by swithcing to the other branch but then I cannot work on my current branch.

Edit: I was able to somehow hack this. By switching to one branch and oppening the gitk. Then without closing the gitk switching to the other branch. However is there more "clean" solution?

Upvotes: 0

Views: 103

Answers (3)

Andreas Løve Selvik
Andreas Løve Selvik

Reputation: 1252

You can view the tree of all branches in gitk, it's just not default.

Go to View -> "New View.." and under References check all the boxes if you want all of it, or enter the specific branches and tags you want to view.

I usually have a view called "All" with all the checkboxes checked. The "Remember this view" is a nice option if you need this regularily, you'll find it next time under 'View'.

Upvotes: 0

Alex Wolf
Alex Wolf

Reputation: 20148

For this case git provides you the show command. You can easily take a look at the message and the changes of a commit by using

git show <commit-reference>

For more information you can take a look at the documentation.

Upvotes: 1

merlin2011
merlin2011

Reputation: 75589

  1. Look at the commit history of the other branch by using git log branchname.

  2. View the diff by using git diff <hash_of_commit> <hash_of_earlier_commit>.

Upvotes: 2

Related Questions