如何知道哪个分支“git log”提交属于? [英] How to know which branch a "git log" commit belongs to?

查看:338
本文介绍了如何知道哪个分支“git log”提交属于?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我做了 git log ,是否有任何参数可以指定从输出中可以知道每个提交属于哪个分支?



编辑:为了澄清,我了解提交可能是两个分支的一部分(例如)。我想要的是获取 log 中的提交所属的最新分支。所以,如果我从 master 创建了一个名为 foo 的分支。它属于两个分支,但我想获得 foo

解决方案

<使用 git log ,您已经获得了当前所在分支的所有提交。



如果您想查看合并分支的提交,您可以使用

  $ git log --pretty = oneline --graph 

创建日志树并查看合并的内容
$ b

- graph 将使提交树和
- pretty = oneline 将为每次提交创建一行可视化文件

向日志添加分支(作为参考):

  $ git log --all --source --pretty = oneline --graph 
   $ b> 

$ git show-branch


If I do git log, is there any parameter I could specify to be able to tell from the output which branch every commit belongs to?

Edit: to clarify, I understand that a commit may be part of two branches (for instance). What I want is to get the most recent branch that the commit in log belongs to. So, if I made a branch called foo from master. It would belong to both branches, but I want to get foo.

解决方案

With git log you already get all the commits from the current branch you are on.

If you want to see commits from merged branches you can use

$ git log --pretty=oneline --graph

To create a log tree and see what merged branches a commit stems from.

--graph will make the commit tree and --pretty=oneline will make a one line visualization for every commit

To add branches (as refs) to the log:

$ git log --all --source --pretty=oneline --graph

To display branches with commits:

$ git show-branch

这篇关于如何知道哪个分支“git log”提交属于?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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