0

I would like a complete list of SHAs that are available/possible to pass to the checkout operation

git checkout <sha-parameter-here>

similar to what I am getting from

git log --pretty=oneline

but a complete listing.

Here is a simple run through:

  • checkout earlier version in master branch using

    git checkout "sha-parameter-from-log"

  • make modifications and commit

    git commit -a -m 'something'

  • at this point the log is "truncated" but contains most SHA of most recent commit.

    git log --pretty=oneline

  • when back to master, the SHA is not listed anymore

    git checkout master

    git log --pretty=oneline

  • HOWEVER, if i remember the SHA from the commit I can STILL perform

    git checkout "sha-not-in-log"

Thanks for any help.

Zoe
  • 27,060
  • 21
  • 118
  • 148
datahaki
  • 600
  • 7
  • 23
  • I edited my answer to reflect your edit. Added the git log oneline-a-like command which will show you the path of divergence on one line! :) – BookOfGreg Nov 03 '14 at 15:34
  • I thank you sincerely for you effort! I already upvoted you answer, but it really doesn't solve my problem of how to get a COMPLETE list of all possible SHA's that could be checkout'ed... The list that I get from your command depends on the currently checkedout version and typically is not complete. – datahaki Nov 05 '14 at 06:38
  • if your name is Linus, please answer my question. – datahaki Aug 16 '15 at 10:36
  • `git rev-list --all --remotes` should be all of them? – BookOfGreg Aug 17 '15 at 08:02

1 Answers1

3

The git rev-list should list all SHAs for all commits with some options. --all will get ones locally and --remotes should show all the non-local commits.

git rev-list --all --remotes

More documentation here.

In addition, for your specific scenario regarding git log oneline, you can change the git log to include diverged branches using the following line:

git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short --all

I've seen this aliased around the internet as 'git hist' on occasion.

BookOfGreg
  • 3,550
  • 2
  • 42
  • 56