11

I would just like to echo the value of ORIG_HEAD at the command line -- how can I do this? To no avail I tried:

$ echo $ORIG_HEAD

and

$ git echo $ORIG_HEAD
Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
tadasajon
  • 14,276
  • 29
  • 92
  • 144
  • 5
    What precisely do you mean by "the value"? You can get the raw SHA-1 with `git rev-parse ORIG_HEAD`, if that's what you're looking for. – torek Jan 05 '15 at 01:03

2 Answers2

14

You can see what commit ORIG_HEAD points to by using the log command of git:

git log -1 ORIG_HEAD

What you tried, $ORIG_HEAD is parsed by your shell, treating it as a variable that was probably not set so effectively running

echo
git echo

Where git echo is an invalid git command.

fejese
  • 4,601
  • 4
  • 29
  • 36
1

If you are just looking for the SHA-1 to be able to pipe to something other command, as @torek mentioned you could do...

git rev-parse ORIG_HEAD

This comes from the .git/ORIG_HEAD file. So you could also do this...

cat .git/ORIG_HEAD

It is of course worth mentioning that ORIG_HEAD and HEAD are not the same. More about that here. So if you came here looking for how to get the SHA-1 of the HEAD use this instead...

git rev-parse HEAD
Daniel Morell
  • 2,308
  • 20
  • 34