如何运行 git log 以仅查看特定分支的更改?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4649356/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I run git log to see changes only for a specific branch?
提问by Highway of Life
I have a local branch tracking the remote/master branch. After running git-pull
and git-log
, the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so many changes made to the remote branch, I need to see just the commits made to the current local branch.
我有一个本地分支跟踪远程/主分支。运行git-pull
and 后git-log
,日志将显示远程跟踪分支以及当前分支中的所有提交。但是,由于对远程分支进行了大量更改,因此我只需要查看对当前本地分支所做的提交。
What would be the Git command to use to only show commits for a specific branch?
用于仅显示特定分支的提交的 Git 命令是什么?
Notes:
笔记:
Configuration information:
配置信息:
[branch "my-branch"]
remote = origin
merge = refs/heads/master
回答by Wayne Conrad
Assuming that your branch was created off of master
, then while in the branch(that is, you have the branch checked out):
假设您的分支是从master
,然后在分支中创建的(即,您已签出分支):
git cherry -v master
or
或者
git log master..
If you are not in the branch, then you can add the branch name to the "git log" command, like this:
如果您不在分支中,则可以将分支名称添加到“git log”命令中,如下所示:
git log master..branchname
If your branch was made off of origin/master
, then say origin/master
instead of master
.
如果您的分支是由 制成的origin/master
,则说origin/master
而不是master
。
回答by yerlilbilgin
Use:
用:
git log --graph --abbrev-commit --decorate --first-parent <branch_name>
It is only for the target branch (of course --graph, --abbrev-commit --decorate are more polishing).
它仅适用于目标分支(当然 --graph、--abbrev-commit --decorate 更加完善)。
The key option is --first-parent: "Follow only the first parent commit upon seeing a merge commit" (https://git-scm.com/docs/git-log)
关键选项是--first-parent:“在看到合并提交时只关注第一个父提交”(https://git-scm.com/docs/git-log)
It prevents the commit forks from being displayed.
它可以防止显示提交叉。
回答by Dyaniyal Wilson
If you want only those commits which are done by you in a particular branch, use the below command.
如果您只想要那些由您在特定分支中完成的提交,请使用以下命令。
git log branch_name --author='Dyaniyal'
回答by GPHemsley
The problem I was having, which I think is similar to this, is that master was too far ahead of my branch point for the history to be useful. (Navigating to the branch point would take too long.)
我遇到的问题(我认为与此类似)是 master 超出了我的分支点太远,因此历史记录没有用。(导航到分支点将花费太长时间。)
After some trial and error, this gave me roughly what I wanted:
经过一些试验和错误,这大致给了我我想要的:
git log --graph --decorate --oneline --all ^master^!
回答by Mahdi Pedram
just run git log origin/$BRANCH_NAME
赶紧跑 git log origin/$BRANCH_NAME