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

前端 未结 6 888
不思量自难忘°
不思量自难忘° 2020-12-04 04:30

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 b

相关标签:
6条回答
  • 2020-12-04 04:51

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

    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.

    0 讨论(0)
  • 2020-12-04 04:53

    For those using Magit, hit l and =m to toggle --no-merges and =pto toggle --first-parent.

    Then either just hit l again to show commits from the current branch (with none of commits merged onto it) down to end of history, or, if you want the log to end where it was branched off from master, hit o and type master.. as your range:

    0 讨论(0)
  • 2020-12-04 04:54

    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'
    
    0 讨论(0)
  • 2020-12-04 05:08

    just run git log origin/$BRANCH_NAME

    0 讨论(0)
  • 2020-12-04 05:13

    Assuming that your branch was created off of master, then while in the branch (that is, you have the branch checked out):

    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 master..branchname
    

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

    0 讨论(0)
  • 2020-12-04 05:13

    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^!
    
    0 讨论(0)
提交回复
热议问题