How do I run git log to see changes only for a specific branch?

匿名 (未验证) 提交于 2019-12-03 01:27:01

问题:

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.

What would be the Git command to use to only show commits for a specific branch?

Notes:

Configuration information:

[branch "my-branch"]   remote = origin   merge = refs/heads/master 

回答1:

Assuming that your branch was created off of master:

git cherry -v master 

or

git log master.. 

If your branch was made off of origin/master, then say origin/master instead of master.



回答2:

Use:

git log --graph --abbrev-commit --decorate  --first-parent 

It is only for the target branch (of course --graph, --abbrev-commit --decorate are more polisihing).

The key option is --first-parent: "Follow only the first parent commit upon seeing a merge commit" (https://git-scm.com/docs/git-log)

It prevents the commit forks from being displayed.



回答3:

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' 


回答4:

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.)

After some trial and error, this gave me roughly what I wanted:

git log --graph --decorate --oneline --all ^master^! 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!