Amadan Amadan - 2 months ago 11
Git Question

List of all git commits?

Let's say that I have a graph like this:

A---B---C---D (master)
\
\-E---F (HEAD)


If I do
git log --all --oneline
, I will get all six of my commits.

But if the graph is

A---B---C---D (master, HEAD)
\
\-E---F


I will not see E and F. Can I get git to tell me all the commits, including those on branches which are not named?

Thanks

Answer Source

Not particularly easily- if you've lost the pointer to the tip of a branch, it's rather like finding a needle in a haystack. You can find all the commits that don't appear to be referenced any more- git fsck --unreachable will do this for you- but that will include commits that you threw away after a git commit --amend, old commits on branches that you rebased etc etc. So seeing all these commits at once is quite likely far too much information to wade through.

So the flippant answer is, don't lose track of things you're interested in. More seriously, the reflogs will hold references to all the commits you've used for the last 60 days or so by default. More importantly, they will give some context about what those commits are.