Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show only history of one branch in a Git log

I am using Git for my project and trying to follow best practice:

  1. I work on a topic branch
  2. When ready, I merge the topic branch into my dev branch using git merge --squash. This keeps my dev branch clean.
  3. Whenever the dev branch is stable and the team decides it's time for a release, we merge the dev branch into the master branch, without using squash, and tag that commit as a version release.

This should keep our history, and using gitk, we can see where all of the commits come in. However, I want to be able to see only the commits applied to the master branch. I have tried:

git log master git show-branch 

None of these show just the history of the master branch. Is there a way to easily do this?

like image 565
Alex Recarey Avatar asked Jan 07 '11 19:01

Alex Recarey


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 I see my git log history?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.

Does git log show all branches?

Graph all git branchesDevelopers can see all branches in the graph with the –all switch. Also, in most situations, the –decorate switch will provide all the supplemental information in a formatted and nicely color-coded way.


1 Answers

If I'm understanding you correctly, you want to see the merges back into master, but not the history of those merges. I believe that:

git log --merges 

will give you what you want.

UPDATE: Adding --first-parent should fix this from the sounds of it.

git log --merges --first-parent 

--first-parent

Follow only the first parent commit upon seeing a merge commit. 

This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.

like image 98
James Kovacs Avatar answered Sep 21 '22 19:09

James Kovacs