在Git日志中仅显示一个分支的历史记录 [英] Show only history of one branch in a Git log

查看:215
本文介绍了在Git日志中仅显示一个分支的历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 我在一个主题分支上工作

    em>

  2. 准备好后,我使用合并主题分支到我的分支壁球。这使我的 dev 分支保持干净。

  3. 当分支稳定并且团队决定发布时,将 dev 分支分支到 master 分支,不使用使用压扁,并将该提交标记为版本发布。

这应该保留我们的历史记录,并使用gitk,我们可以看到所有提交进入的位置。但是,我希望只能看到 / strong>应用于 master 分支的提交。我已经尝试过:

$ g $ log $ g $ b $ g $ g $ show
code $ g $

这些都不能显示 master 分支的历史记录。有没有一种方法可以轻松地做到这一点? 解决方案

如果我正确理解你,你想看到合并回到主人,但不是那些合并的历史。我相信:

  git log --merges 

会给你想要的东西。



更新:添加--first-parent应该从它的声音。

  git log --merges --first-parent 

$ b


- 第一父母

 在查看合并提交后,只跟踪第一个父提交。 

在查看
的演变时,此选项可以提供更好的概览
特定的主题分支,因为
合并到主题分支往往只是
,关于适时调整到更新的
,并且这个
选项允许您忽略
通过这种合并带入您的
历史记录中的单个提交。



I am using Git for my project and trying to follow best practice:

  1. I work on a topic branch
  2. When ready, I merge the topic branch into my dev branch using git merge --squash. This keeps my dev branch clean.
  3. Whenever the dev branch is stable and the team decides it's time for a release, we merge the dev branch into the master branch, without using squash, and tag that commit as a version release.

This should keep our history, and using gitk, we can see where all of the commits come in. However, I want to be able to see only the commits applied to the master branch. I have tried:

git log master
git show-branch

None of these show just the history of the master branch. Is there a way to easily do this?

解决方案

If I'm understanding you correctly, you want to see the merges back into master, but not the history of those merges. I believe that:

git log --merges

will give you what you want.

UPDATE: Adding --first-parent should fix this from the sounds of it.

git log --merges --first-parent

--first-parent

Follow only the first parent commit upon seeing a merge commit.

This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.

这篇关于在Git日志中仅显示一个分支的历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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