Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 
like image 538
Highway of Life Avatar asked Jan 10 '11 17:01

Highway of Life


People also ask

How do I commit history to only one branch?

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.

How do you view changes in a particular commit?

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 .


2 Answers

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.

like image 146
Wayne Conrad Avatar answered Oct 07 '22 10:10

Wayne Conrad


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.

like image 25
yerlilbilgin Avatar answered Oct 07 '22 11:10

yerlilbilgin