Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View git log without merge commits

Tags:

git

git-log

I'm trying to view commits made by a specific user, and want to remove any merges done by the user from the output. How can I do so?

I can check for the commits of a user using git log --author=<name>, but can't remove the merge commits in the output.

PS: Merge conflicts do not happen in the workflow of the repo in question, all branches are rebased before merging into master so it is safe to remove the merge commits from the output, and similarly, two feature branches are not merged with one another raising the possiblity.

like image 374
Anshul Goyal Avatar asked Mar 11 '16 17:03

Anshul Goyal


People also ask

Does git merge keep history?

In the Conceptual Overview section, we saw how a feature branch can incorporate upstream changes from main using either git merge or git rebase . Merging is a safe option that preserves the entire history of your repository, while rebasing creates a linear history by moving your feature branch onto the tip of main .

What is git merge log?

By default, git log includes merge commits in its output. But, if your team has an always-merge policy (that is, you merge upstream changes into topic branches instead of rebasing the topic branch onto the upstream branch), you'll have a lot of extraneous merge commits in your project history.


2 Answers

use

git log --author=<name> --no-merges 

Additionally the --first-parent option may give useful result for you:

--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. Cannot be combined with --bisect.

like image 195
0xAX Avatar answered Nov 13 '22 12:11

0xAX


You can omit merges with --no-merges:

git log --no-merges --author=<name> 

See the git log manpage for details.

like image 22
morxa Avatar answered Nov 13 '22 12:11

morxa