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
I think an option for your purposes is git log --oneline --decorate . This lets you know the checked commit, and the top commits for each branch that you have in your story line. By doing this, you have a nice view on the structure of your repo and the commits associated to a specific branch.
Looking up changes for a specific commit If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With