How to show git log with branch name

主宰稳场 提交于 2019-11-28 21:19:23
Jeff Bowman
$ git log --graph --decorate --oneline
* 1f3e836 (HEAD, origin/v2, v2) Change scripts to new format.
*   34d458f (origin/master, master) Merge branch 'new-shell'
|\  
| * 995ece7 (origin/new-shell) Fix index.html and add script pushing.
| * fe0615f New shell hello-world.
|/  
* fe1b1c0 Progress.
...

git log --graph --decorate --oneline should show you names of the commits that have names. Not every commit is associated with a branch name.

Remember, a branch name is just a pointer to a particular commit. Each commit has a parent, so one commit may be a part of the history of a dozen separate branches.

  • You can see which branches contain a commit via git branch --contains <ref>.
  • If you just need some kind of symbolic name to track down a commit, use git name-rev <ref>.
  • If you need a shell-scriptable ("plumbing") list of all branches containing a commit, try this:

    commit=$(git rev-parse <ref>) # expands hash if needed
    for branch in $(git for-each-ref --format "%(refname)" refs/heads); do
      if git rev-list "$branch" | fgrep -q "$commit"; then
        echo "$branch"
      fi
    done
    

See also: SO: Finding what branch a commit came from

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