如何显示分支名称的git日志 [英] How to show git log with branch name

查看:121
本文介绍了如何显示分支名称的git日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着 git log w / - 装饰和 - source code>选项。但是仍然无法获得提交的分支名称 2f3cb60 d7e7776 ,为什么?

  #git log 2f3cb60 --graph --decorate --source --all --oneline 
...
* | | | 1920ad5 refs / heads / gpio支持gpio lib
| | / /
| / | |
* | | 2f3cb60 2f3cb60修复
* | | d7e7776 2f3cb60修复
| | /
| / |
* | aa4dcfb refs / remotes / origin / httpd支持
* | cfc839d refs / remotes / origin / httpd添加文件夹

如何使用分支名称显示git log?

解决方案

  $ git log --graph --decorate --oneline 
* 1f3e836(HEAD,origin / v2,v2)将脚本更改为新格式。
* 34d458f(origin / master,master)合并分支'new-shell'
| \
| * 995ece7(origin / new-shell)修复index.html并添加脚本推送。
| * fe0615f新壳你好,世界。
| /
* fe1b1c0进度。
...

git log --graph --decorate --oneline 应该显示具有名称的提交的名称。 并非每个提交都与分支名称相关联。



请记住,分支名称只是指向特定提交的指针。每个提交都有一个父代,所以一个提交可能是十几个独立分支历史的一部分。


  • 您可以看到哪些分支包含通过 git branch --contains< ref>

  • 进行提交如果您只需要某种符号名称来追踪使用 git name-rev

  • 如果您需要shell脚本(plumbing)包含提交的所有分支的列表,试试这个:


    $ b $

      commit = $(git rev-parse< ref>)#如果需要,展开散列
    用于$(git for- each-ref - 格式%(refname)refs / heads);如果git rev-list$ branch|做
    fgrep -q$ commit;然后
    echo$ branch
    fi
    done




另请参阅: SO:寻找提交来自哪个分支


I try git log w/ --decorate and --source options. But still can not get the branch name of commit 2f3cb60 and d7e7776, Why?

#git log 2f3cb60 --graph  --decorate --source --all --oneline
...
* | | | 1920ad5 refs/heads/gpio support gpio lib
| |/ /
|/| |
* | | 2f3cb60   2f3cb60 fix
* | | d7e7776   2f3cb60 fix
| |/
|/|
* | aa4dcfb     refs/remotes/origin/httpd support
* | cfc839d     refs/remotes/origin/httpd add folder

How do I show git log with branch name?

解决方案

$ 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

这篇关于如何显示分支名称的git日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆