开发者

How does a git branch relate to other branches in my repo?

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.


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.


try to use

gitk --all


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜