2

I want to log all commits pushed to a Git repository. I'm interested in all commits, not only in the branches I have checked out locally. Also I want to see commits that happened in branches that have been deleted already. All I need is a command similar to svn log (in Subversion). Is it possible at all?

yegor256
  • 102,010
  • 123
  • 446
  • 597
  • Possible duplicate of : http://stackoverflow.com/questions/746684/how-to-search-through-all-commits-in-the-repository – Jessedc Sep 16 '12 at 11:55
  • `--walk-reflogs` option doesn't help when I'm interested in locally absent branches – yegor256 Sep 16 '12 at 11:56

1 Answers1

3

I'm not sure what you're asking for, but I don't think it's possible in the git world.

I can clone your repo, and make some commits. But I'm not obliged to share them with you. So there are some commits you'll never know about.

Similarly, if I do share commits with you, I might make 10 commits locally, but squash them into 1 commit before sending them to you. You won't be able to tell that the 10 original commits ever existed.

You can make a local branch, make some commits, then delete that branch without merging them back in, and git gc may well destroy those commits forever as they are no longer reachable.

So there are some commits which you can never know about, either because someone made them but never shared them with you, or because you made them but later made them available for garbage collection by deleting the only branch which referenced them.

If you want to see all commits which you do know about, gitk --all might be what you're looking for. It will show you a graphical view of all commits reachable from all branches, local or remote. Similarly, git log --all will show you a text summary of all commits reachable from all branches.

If you're specifically looking for dangling commits on the remote repo, I'm not sure how to do this. git fetch by default fetches only commits reachable from branches; you can specify -t to get those reachable from tags; but I don't think you can fetch the remote reflog.

Community
  • 1
  • 1
Philip Potter
  • 8,975
  • 2
  • 37
  • 47
  • 2
    This answer should be pruned to the essence `git log --all` and spare readers all that strayed disquisition from paragraphs 1-5 (the question was obvious enough from the beginning "pushed to a repository"). – bloody Dec 08 '22 at 12:37