290

I need to get the report of all commits that the author did. So far, I have the script that wraps the following command:

git log --pretty=format:"%ad:%an:%d:%B" --date=short --reverse --all --since=2.months.ago --author=Petr

It works fine. However, it reports only the actions of the current branch. Is there any option that would log the commit messages for the author from all branches, not only from the current one?

In other words, can git make a reverse sorted (by datetime) sequence of all the commits in repository and extract the log info from that sequence?

Solved: (copied from the comment below that is hidden otherwise)

The problem was that I have one repository and two clones to work concurrently on two branches. I did push the changes to the origin repository, but I forgot to fetch the changes to the cloned repository. This way it seemed that --all did not work when using it for the cloned repository.

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
pepr
  • 20,112
  • 15
  • 76
  • 139
  • Guess you can write a shell script for that: `git log` accepts `committish` as its first argument: `git log mybranch` (and list all you branches with `git branch`). – Alexander Pavlov Apr 27 '12 at 10:55
  • @AlexanderPavlov: I probably do not understand. What is the `committish`? Is it possible to get the information via one git command? – pepr Apr 27 '12 at 11:21
  • Oh, `committish` denotes a branch or a commit (or HEAD). This does not seem to be possible with plain `git log` (since it uses `git rev-list` behind the curtains, which will _"List commits that are reachable by following the parent links from the given commit(s), but exclude commits that are reachable from the one(s) given with a ^ in front of them. The output is given in reverse chronological order by default."_ I'll try to come up with a viable shell script solution. – Alexander Pavlov Apr 27 '12 at 11:43
  • 2
    I'm getting commits from all branches, not only the current one? This is expected since you provide `--all`. Your command is correct – CharlesB Apr 27 '12 at 11:44
  • 1
    @AlexanderPavlov: Don't bother with `git rev-list` parsing, `git log --all` is OK. – CharlesB Apr 27 '12 at 11:45
  • 1
    @CharlesB: That was what I thought about the `--all`, but it apparently does not work this way for me. I do not understand its help explanation: Pretend as if all the refs in `refs/` are listed on the command line as ``. – pepr Apr 27 '12 at 12:50
  • does a simple `git log --all` misses branches? – CharlesB Apr 27 '12 at 12:51
  • @CharlesB: Yes and no! You could not know my situation, and I did not know what should I describe. The problem is that I have one repository and two clones to work *concurently* on two branches. I did push the changes to the *origin* repository, but I forgot to fetch the changes to the cloned repository. Please formulate the comment to accept it. If possible, how can I run the command against the origin repository? The *origin* is the bare repository and the script is contained in the repository. (Otherwise, I will fetch from origin first [in the script].) – pepr Apr 27 '12 at 13:02

2 Answers2

269

Your command is right, since you use the --all switch which gives all commits from all branches. To answer the question in your comment, it works also in bare repositories.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
101

Instead of --all you may want to use --branches, since --all also includes refs/tags and refs/remotes.

Gert Hengeveld
  • 2,478
  • 1
  • 18
  • 13