How can I view a git log of just one user's co

2019-01-02 16:40发布

When using git log, how can I filter by user so that I see only commits from that user?

13条回答
旧时光的记忆
2楼-- · 2019-01-02 16:46

Since the other question was (possibly wrongfully so?) locked, I will just put this here:

show authors with their commit counts:

git shortlog -nse

find all commits for specific USERNAME:

git log --author=USERNAME --oneline | awk '{print $1}' | xargs git show
查看更多
柔情千种
3楼-- · 2019-01-02 16:55
git log --author="that user"
查看更多
皆成旧梦
4楼-- · 2019-01-02 16:55
cat | git log --author="authorName" > author_commits_details.txt

This gives your commits in text format.

查看更多
人气声优
5楼-- · 2019-01-02 16:55

Show n number of logs for x user in colour by adding this little snippet in your .bashrc file.

gitlog() {
    if [ "$1" ] && [ "$2" ]; then
       git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order -n "$1" --author="$2"
    elif [ "$1" ]; then
       git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order -n "$1"
    else
        git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order
    fi
}

alias l=gitlog

To show the last 10 commits by Frank:

l 10 frank

To show the last 20 commits by anyone:

l 20

查看更多
刘海飞了
6楼-- · 2019-01-02 16:58

try this tool https://github.com/kamranahmedse/git-standup

Usage

```bash
$ git standup [-a <author name>] 
              [-w <weekstart-weekend>] 
              [-m <max-dir-depth>]
              [-f]
              [-L]
              [-d <days-ago>]
              [-D <date-format>] 
              [-g] 
              [-h]
```

Below is the description for each of the flags

- `-a`      - Specify author to restrict search to (name or email)
- `-w`      - Specify weekday range to limit search to (e.g. `git standup -w SUN-THU`)
- `-m`      - Specify the depth of recursive directory search
- `-L`      - Toggle inclusion of symbolic links in recursive directory search
- `-d`      - Specify the number of days back to include
- `-D`      - Specify the date format for "git log" (default: relative)
- `-h`      - Display the help screen
- `-g`      - Show if commit is GPG signed or not
- `-f`      - Fetch the latest commits beforehand
查看更多
怪性笑人.
7楼-- · 2019-01-02 17:00

You can even abbreviate this a bit by simply using part of the user name:

git log --author=mr  #if you're looking for mrfoobar's commits
查看更多
登录 后发表回答