tags:

views:

40

answers:

4

I'd like to view the context of commits around a git branch: any nearby ancestors or descendants in my repo. This is easy with gitk if the branch is recent and appears at the top. It's tedious if the branch is old.

+1  A: 

try to use

gitk --all
second
A: 

Ancestors are easy. Descendants, not so much. If you want to guarantee that all descendants are visible in gitk, use the --all option, as second suggested. (You can also go to view > new view and check the "all refs" or "all (local) branches" boxes, if you've already started gitk.)

If you started gitk with the --all option, it'll display everything but still come up scrolled to your current branch. If that's not the one you want, hit F2 or go to File > List references and find the appropriate branch in the list - clicking on it will center the view there.

Jefromi
+1  A: 

In addition to the very nice and visual gitk --all (which is my preference) you can also use git show-branch. This will show you which commits are unique to which branches. The output is a bit cryptic, but there's a nice tutorial on the command.

Pat Notz
git show-branch --topics master heads/*
Vincent Scheib
"--topics master" suppresses the many commits in master I'm not focused on. "heads/*" shows all the local branches, nicer than --all which is spammy with too many remote branches.
Vincent Scheib
A: 
git log --graph --format=oneline branch~10..branch 
                                 branch~10..master 
                                 branch~10..everyOtherBranch ...

Then, scroll to the very end of the file ("G" in less). 10 is a magic number to push the history back far enough to see context, make it large enough to see the common ancestor.

But listing every branch is tedious. Using --all is OK if you memorize the SHA for one of the commits on the branch, and then search for it. But that's not great either.

Vincent Scheib