How to resolve error: short SHA1 <CommitHash> is ambiguous?

Viewed 705

I used git show and I get the following error,

error: short SHA1 94817b is ambiguous
hint: The candidates are:
hint:   94817b5aaa blob
hint:   94817b8c74 blob
fatal: ambiguous argument '94817b': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

I'm trying to get the file in specific version of commit, I obtained the short commit hash from the diff object

1 Answers

You can tell git-diff to give you the full SHA-1 of the blobs instead of the abbreviated version using the --full-index option:

Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.

For example:

git diff --full-index HEAD^..HEAD

will result in a diff header that looks like this:

diff --git a/path/to/file b/path/to/file
index 25c0cfd42393302780668d0f58c6c48333dc1f89..cf913856f0475d360ff45cc244568b53c56a5554 100644

instead of this:

diff --git a/path/to/file b/path/to/file
index 25c0cfd..cf91385 100644
Related