How do I see a commit's path through git history, or “how it got in the current branch”?

喜欢而已 提交于 2019-12-03 03:52:19

For the latter part of your question, "how it got in the current branch?", take a look at git-when-merged.

It's a Python script that will, per its readme:

Find when a commit was merged into one or more branches. Find the merge commit that brought COMMIT into the specified BRANCH(es). Specifically, look for the oldest commit on the first-parent history of BRANCH that contains the COMMIT as an ancestor.

This sounds like what you're looking for in the case of determining when the {sha1hashIDstring} commit was merged into test_jan15 branch.

This is a classic case of git bisect. bisect help you trace bugs. In your case you simply looking for a commitId (which is misplaced into the wrong branch).

Bisect is a very simple yet powerful tool.

http://git-scm.com/docs/git-bisect http://hashrocket.com/blog/posts/finding-failure-git-bisect

Hope it will help you out.

Have you tried the "--decorate" option to git log?

I have this alias in my .gitconfig:

[alias]

        k = log --graph --oneline --abbrev-commit  --decorate

It shows a similar graph as the one shown by gitk, with the branch names "decorated" besides the most recent commit in the branch.


OR

--

Try tig as well. It is more informative than gitk (as per my usage ;)). Refer to http://gitready.com/advanced/2009/07/31/tig-the-ncurses-front-end-to-git.html once. I think either solution will give you required results.

I googled something and got something for you. credit goes to #vonC

git when-merged [OPTIONS] COMMIT [BRANCH...]

Find when a commit was merged into one or more branches. Find the merge commit that brought COMMIT into the specified BRANCH(es).

Specificially, look for the oldest commit on the first-parent history of BRANCH that contains the COMMIT as an ancestor.

git-what-branch

Discover what branch a commit is on, or how it got to a named branch This is a Perl script from Seth Robertson that seems very interesting:

SYNOPSIS

git-what-branch [--allref] [--all] [--topo-order | --date-order ]
[--quiet] [--reference-branch=branchname] [--reference=reference]
<commit-hash/tag>...
OVERVIEW

Tells us (by default) the earliest causal path of commits and merges to cause the requested commit got onto a named branch. If a commit was made directly on a named branch, that obviously is the earliest path.

By earliest causal path, we mean the path which merged into a named branch the earliest, by commit time (unless --topo-order is specified).

PERFORMANCE

If many branches (e.g. hundreds) contain the commit, the system may take a long time (for a particular commit in the linux tree, it took 8 second to explore a branch, but there were over 200 candidate branches) to track down the path to each commit. Selection of a particular --reference-branch --reference tag to examine will be hundreds of times faster (if you have hundreds of candidate branches).

**EXAMPLES**
 # git-what-branch --all 1f9c381fa3e0b9b9042e310c69df87eaf9b46ea4
 1f9c381fa3e0b9b9042e310c69df87eaf9b46ea4 first merged onto master using the following minimal temporal path:
   v2.6.12-rc3-450-g1f9c381 merged up at v2.6.12-rc3-590-gbfd4bda (Thu May  5 08:59:37 2005)
   v2.6.12-rc3-590-gbfd4bda merged up at v2.6.12-rc3-461-g84e48b6 (Tue May  3 18:27:24 2005)
   v2.6.12-rc3-461-g84e48b6 is on master
   v2.6.12-rc3-461-g84e48b6 is on v2.6.12-n
   [...]

I know this isn't tagged with "github" - but if the project is on there the visual style of Blame or History (buttons in file header when viewing a specific file) can make it a lot easier to trace when things happened.

Not sure if that actually solves this (very) specific issue - but it might help others with similar issues who find this question...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!