8

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
  • 53,152
  • 13
  • 97
  • 112
tadasajon
  • 13,329
  • 27
  • 84
  • 138
  • 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

13

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,481
  • 4
  • 27
  • 36
0

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
  • 1,767
  • 17
  • 28