Tracking history of a branch
How can I see the history of a particular branch?
I have been creating and merging branches. However, on one particular branch say for example new_feature
. I want to know the history of what has been merged into this branch, and what branch this was created from?
The reason is I have this new_feature
branch, and I want to know what other branches was merged into it, and what branch the new_feature
was made开发者_JS百科 from?
I an not really interested in using any GUI tools, maybe some on the command line. I'm using Git version 1.7.5.4 and Ubuntu 11.10.
git log --oneline --graph --all
may give you what you want, without the need for third-party tools.
--oneline
makes the commits display on one line only, instead of the longer default format.--graph
shows branch/merge history with ASCII characters.--all
shows all branches in the history, not just the current one.
You can see only merge commits with git log --merges
. As long as you haven't messed with your merge commit messages, you'll see what branches you've merged. (If you don't want to use HEAD
as a starting point, provide a commit/branch/tag as an argument.) Tweak the output to your liking with other options - see the man page. You might like --oneline
(one line commit summaries) or even --pretty=%s
(print only commit subjects). You might also like --first-parent
, which by following only the first parents of merges, prevents it from reporting commits from the merged branches.
Knowing what branch a branch started from is a little trickier - that's not really information that gets recorded. You might find it as the first (bottom) entry in the output of git reflog <branch>
, if it was recent enough.
I often use tig
, which is a text mode repository browser for Git. However, the gitk
program that comes with Git is also useful for viewing repository history, because sometimes the lines between branches can get pretty complicated and it's easier to see in a GUI tool.
For low-level history, the git reflog
command will show you all the actions that have caused the current (or specified) branch head to move.
精彩评论