仅显示 Git 日志中一个分支的历史记录
我正在为我的项目使用 Git,并尝试遵循最佳实践:
- 我在主题分支上工作。
- 准备好后,我将主题分支合并到我的开发中em> 使用 git merge --squash 进行分支。这使我的 dev 分支保持干净。
- 每当 dev 分支稳定且团队决定发布版本时,我们就会将 dev 分支合并到 master 分支,不使用压缩,并将其标记为版本发布。
这应该保留我们的历史记录,并且使用 gitk,我们可以看到所有提交的来源。但是,我希望能够仅看到应用于master 分支机构。我已经尝试过:
git log master
git show-branch
这些都没有仅仅显示master分支的历史。有没有办法轻松做到这一点?
I am using Git for my project and trying to follow best practice:
- I work on a topic branch
- When ready, I merge the topic branch into my dev branch using
git merge --squash
. This keeps my dev branch clean. - 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我理解正确的话,您希望看到合并回 master,而不是这些合并的历史记录。我相信:
会给你你想要的。
更新:添加 --first-parent 应该可以从声音中解决这个问题。
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:
will give you what you want.
UPDATE: Adding --first-parent should fix this from the sounds of it.
不幸的是,Git 不存储提交的分支信息,并且提交不属于分支。 Git 中的分支只是一系列提交中的“移动标签”,而不是人们所期望的一系列提交。
所以基本上你不能显示属于分支的提交,因为 Git 中没有这样的概念。
Unfortunately, Git does not store branch information for a commit, and commits do not belong to a branch. Branches in Git are just "moving tags" in a course of commits and NOT a sequence of commits as one would expect.
So basically you cannot show commits that belong to a branch since there is no such concept in Git.
由于 Git 不存储有关哪个分支是哪个分支的新生信息,因此没有自动方法来猜测您可能想要显示哪个分支。
在这方面,
--first-parent
最终不会有帮助,尤其是因为很容易拥有多个主人。考虑一下:(随意选择一个随机项目并做这个练习。)将其绘制成图表。因此,即使提交被标记为它们所在的分支的名称(因为两者都是主分支),您也无法有意义地绘制“仅一个分支”的图表。
Since Git does not store information about which branch is nascent from which other, there is no automatic way to guess which branch you could possibly want to be shown.
In that regard,
--first-parent
will not ultimately help, especially since it is easy to have more than one master, for example. Consider:(Feel free to take a random project and do this exercise.) Graph it. So you cannot meaningfully graph "just one branch", even if the commits were tagged with the name of the branch they were made on (because both are master).