Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git log without an author's commits

Tags:

git

There's a project we're working on where the majority of commits are added in by a front-end developer. He's editing mainly HTML, CSS, JavaScript files that are not related to the back-end work that I'm helping with. It would be great if I could show the git log minus commits added by the front-end developer, so I could get a view of commits just related to the backend.

Is there an option I can pass to git log that would allow me to exclude all commits by an author? I just want to exclude this one developer's commits, I still care about viewing commits from other developers as well.

like image 346
Elliot Larson Avatar asked Jul 25 '13 18:07

Elliot Larson


People also ask

Can you hide commits?

You can hide, edit, or delete comments on issues, pull requests, and commits.

What is git log -- Oneline?

Git Log Oneline The oneline option is used to display the output as one commit per line. It also shows the output in brief like the first seven characters of the commit SHA and the commit message.

What is the difference between author and committer in git?

You may be wondering what the difference is between author and committer. The author is the person who originally wrote the work, whereas the committer is the person who last applied the work.


2 Answers

You need a Regular expression to match a line that doesn't contain a word? Negative lookahead will do just that, but you have to ask git to use --perl-regexp.

git log --author='^(?!krlmlr).*$' --perl-regexp

According to git help log,

--perl-regexp ... requires libpcre to be compiled in.

Apparently, not all gits out there have this; for the one shipped with Ubuntu 13.04, this works out of the box.

like image 176
krlmlr Avatar answered Oct 24 '22 18:10

krlmlr


git rev-list --format='%aN' --all \
| sed 'N;/\nauthorname$/d;s/commit \(.*\)/\n.*/\1/' \
| git log --stdin

and of course substitute whatever heads you want for --all above.

Edit: list/select/process pipelines like this are bread and butter, it's just how git (like a lot of unix tools) was built.

like image 21
jthill Avatar answered Oct 24 '22 18:10

jthill