Jak mogę wyświetlić Dziennik zmian tylko jednego użytkownika?

Podczas używania git log, Jak mogę filtrować według użytkownika, aby zobaczyć tylko commity od tego użytkownika?

Author: David Thibault, 2010-11-23

15 answers

To działa zarówno dla git log jak i gitk - 2 najczęstsze sposoby przeglądania historii.
Nie musisz używać całej nazwy:

git log --author="Jon"

Dopasuje commit stworzony przez"Jonathana Smitha"

git log --author=Jon

I

git log --author=Smith

Też by zadziałało. Cudzysłowy są opcjonalne, jeśli nie potrzebujesz spacji.

Dodaj --all, jeśli chcesz przeszukać wszystkie gałęzie, a nie tylko przodków bieżącego commita w swoim repo.

Można również łatwo dopasować na wielu autorzy jako regex jest podstawowym mechanizmem tego filtra. Więc aby wymienić commity Jonathana lub Adama, możesz to zrobić:

git log --author="\(Adam\)\|\(Jon\)"

Aby wykluczyć commity danego autora lub zbioru autorów używając wyrażeń regularnych, jak zaznaczono w tym pytaniu , możesz użyć negatywnego spojrzenia w połączeniu z przełącznikiem --perl-regexp:

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

Alternatywnie możesz wykluczyć commity autorstwa Adama używając bash i piping:

git log --format='%H %an' | 
  grep -v Adam | 
  cut -d ' ' -f1 | 
  xargs -n1 git log -1

Jeśli chcesz wykluczyć committs commited (ale niekoniecznie autor) by Adam, replace %an with %cn. Więcej szczegółów na ten temat znajduje się w moim wpisie na blogu tutaj: http://dymitruk.com/blog/2012/07/18/filtering-by-author-name/

 1830
Author: Adam Dymitruk,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-07-13 08:22:16
git log --author="that user"
 50
Author: wilhelmtell,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-23 19:35:17

Na GitHubie istnieje również secret way...

Możesz filtrować zmiany według autora w widoku zmian, dodając param ?author=github_handle. Na przykład link https://github.com/dynjs/dynjs/commits/master?author=jingweno pokazuje listę commitów do projektu Dynjs

 48
Author: slott,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-11-11 11:34:49
git help log

Wyświetla stronę podręcznika git log. Wyszukaj tam "author", naciskając/, a następnie wpisując "author" , a następnie Enter. Wpisz" n " kilka razy, aby dostać się do odpowiedniej sekcji, która ujawnia:

git log --author="username"

Jak już sugerowałem.

Zauważ, że to da ci autora commitów, ale w Git, autorem może być ktoś inny niż commit (na przykład w jądrze Linuksa, jeśli wyślesz łatkę jako zwykły użytkownik, może ona zostać zatwierdzona przez innego administratora użytkownik.) Zobacz różnicę między autorem a committerem w Git? Po Więcej Szczegółów)

Przez większość czasu to, co określa się jako użytkownika, jest zarówno committerem, jak i autorem.

 31
Author: ustun,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 11:47:32

Aby wyciągnąć więcej szczegółów - (tutaj %an odnosi się do autora)

Użyj tego: -

git log --author="username" --pretty=format:"%h - %an, %ar : %s"
 24
Author: Sireesh Yarlagadda,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-11-11 11:33:48
cat | git log --author="authorName" > author_commits_details.txt

Daje to commity w formacie tekstowym.

 17
Author: Johnsa Philip,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-11-11 11:34:07

Jeśli chcesz filtrować własne commity:

git log --author="<$(git config user.email)>"
 16
Author: Luca Faggianelli,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-11-22 13:57:54

Możesz nawet skrócić to nieco, po prostu używając części nazwy użytkownika:

git log --author=mr  #if you're looking for mrfoobar's commits
 12
Author: three,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-03-24 18:54:37

Wypróbuj to narzędzie https://github.com/kamranahmedse/git-standup

Użycie

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

Poniżej znajduje się opis każdej z FLAG

- `-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
 12
Author: InsaneBot,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-06-19 12:19:15

Ponieważ drugie pytanie było (być może niesłusznie tak?) zablokowane, tylko to tu umieszczę:

Pokaż autorów z ich liczbą commitów:

git shortlog -nse

Znajdź wszystkie commity dla konkretnej nazwy użytkownika:

git log --author=USERNAME --oneline | awk '{print $1}' | xargs git show
 8
Author: sjas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-09-17 15:11:18

Pokaż n liczbę logów dla X Użytkownika w Kolorze, dodając ten mały fragment w swoim .plik bashrc.

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

Aby pokazać ostatnie 10 commitów Franka:

l 10 frank

Aby pokazać ostatnie 20 commitów przez kogokolwiek:

l 20

 5
Author: Frank Forte,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-03-09 03:53:19

Jeśli używasz GitHub:

  • przejdź do gałęzi
  • Kliknij na commity

Wyświetli listę w poniższym formacie

branch_x: < comment> 
author_name committed 2 days ago
  • aby zobaczyć commit poszczególnych autorów; kliknij author_name i tam możesz zobaczyć wszystkie commity tego autora na tej gałęzi
 4
Author: diEcho,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-12-02 11:48:53

Możesz użyć = lub "spacja". Na przykład po wykonaniu dwóch poleceń zwraca to samo

git log --author="Developer1"

git log --author "Developer1"
 2
Author: harshainfo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-07-11 18:51:17

Chociaż jest wiele przydatnych odpowiedzi. Natomiast, aby dodać inny sposób do niego. Możesz również użyć

git shortlog --author="<author name>" --format="%h %s"

Wyświetli wynik w sposób pogrupowany:

<Author Name> (5):
  4da3975f dependencies upgraded
  49172445 runtime dependencies resolved
  bff3e127 user-service, kratos, and guava dependencies upgraded
  414b6f1e dropwizard :- service, rmq and db-sharding depedencies upgraded
  a96af8d3 older dependecies removed

Tutaj, w sumie 5 commitów jest wykonywanych przez <Author Name> pod bieżącą gałęzią. Podczas gdy, możesz również użyć --all, aby wymusić wyszukiwanie wszędzie (wszystkie gałęzie) w repozytorium git.

Jeden haczyk: git wewnętrznie próbuje dopasować wejście <author name> z imieniem i adresem e-mail autora w baza danych git. Jest to rozróżnianie wielkości liter .

 2
Author: surajs1n,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-08-19 15:41:02

Mój przypadek: używam source tree, wykonałem następujące kroki:

  1. wciśnięty CRL+3
  2. zmieniono listę autorów
  3. Wpisz nazwę "Vinod Kumar"

Tutaj wpisz opis obrazka

 1
Author: Vinod Kumar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-08-15 23:48:36