3

I have many repos, in which I need to find some commit I made a very long time ago. Due to reasons, I don't know which repos I have commits in, and when I did those commits.

I could go over them one by one, looking for when I did commits.

Is there some API or UI to just see all commits by a user, to any repo, sorted by time?

torek
  • 448,244
  • 59
  • 642
  • 775
Gulzar
  • 23,452
  • 27
  • 113
  • 201
  • The *Git* answer is: "I don't look anywhere but one repository on your computer: clone all your repos, and then run one Git command per repo to search them all on your own laptop". There might be a better-for-you Bitbucket web site or API answer, though. – torek May 15 '22 at 16:01

1 Answers1

4

You could use git's -C option with each of your repo paths to run git commands in them. Depending how your repos are locally organized, you may want to change how the paths are discovered. Change username to your committer email address. The pattern just needs to be unique, so you can probably leave off @example.com. Change the --before option as needed.

#!/usr/bin/env bash

for d in ~/path-to-repos/*/.git; do
    r=${d%.git}
    echo "$r"
    git -C "$r" log \
        --committer=username \
        --before=2013 \
        --reverse \
        --pretty='format:%h  %cd  %s'
done

You might want to experiment with git log's --pretty options.

Cole Tierney
  • 9,571
  • 1
  • 27
  • 35
  • This forces me to clone everything, I was looking to avoid that. Or, did you mean I can do that directly on the repos inside bitbucket somehow? – Gulzar May 15 '22 at 16:18
  • You would need to clone them. I missed the part where you want to do this _in_ Bitbucket. – Cole Tierney May 15 '22 at 16:33
  • Looks like you can get a listing of repos in Bitbucket using an API which would help automate cloning them all. – Cole Tierney May 15 '22 at 16:44
  • It might be good to add `--no-pager` option before the `log` command. – ADTC Aug 31 '22 at 05:01