110

Git windows command line, version 1.8.0

I have 3 commits so far and when I type

git reset --soft HEAD^

new line comes up with

More?

and flashing cursor for input

Then, whatever I type, I always get

fatal: ambiguous argument 'HEAD ': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]

All other commands works fine in the same folder.

3
  • 18
    If you're using Windows, you could do git log HEAD^^, I believe.
    – SuperDisk
    Nov 4, 2013 at 0:58
  • To avoid any other kinds of escaping in git commands, I started to use git bash instead of windows' command prompt. Git for Windows provides a BASH emulation used to run Git from the command line. So if you install git for windows, you will be able to run your git commands in the Git Bash. I prefer this because, this way you will be used to write git command in platform agnostic way. Your commands wont be different than that you wrote in linux or mac machines.
    – adnan2nd
    Oct 20, 2017 at 16:43
  • "git reset --soft HEAD^^" is what Windows wants. So the answer to the More? prompt is "^"
    – AndrewR
    Oct 6, 2021 at 14:17

5 Answers 5

103

see if git log HEAD^ works. If it doesn't, it may be something with your localization or terminal. It seems to be filtering out the ^ symbol. As a workaround, use git reset --soft HEAD~1 for now.

3
  • 2
    git log HEAD^ throws exactly same scenario, though git reset --soft HEAD~1 workaround works fine Jan 7, 2013 at 21:53
  • 1
    Thank you, workaround helps. More is asking no more. Mar 24, 2016 at 12:35
  • On Windows, where this is a problem, the simpler answer is that you need to quote the carret. Use "HEAD^" instead of HEAD^.
    – joanis
    Aug 27, 2022 at 17:54
55

Your shell is interpreting the ^ symbol as a line continuation symbol. Either just avoid using ^ as Adam suggests:

git reset --soft HEAD~1

or quote the argument so the shell doesn't attempt to interpret it (I'm not sure exactly which shell you're using, but I'd be surprised if this doesn't work):

git reset --soft "HEAD^"
1
  • This is quite common a problem :)
    – Romain
    Jan 8, 2013 at 10:25
38

The ^ is an escape character in the Windows Command Line. Use ^^ instead of ^.

git reset --soft HEAD^^

See Rob Van Der Woude's Scripting Pages for details on Escape Characters.

0
0

For Windows OS,

git log HEAD^^

will work. I have run this command and from the three files it uncommit the most recent one and shows the other two files. The other two files are in below. So, hopefully it will work.

`C:\Users\pqplz947\Desktop\saumen>git log HEAD^^

commit b8b6591a468e4c9d412a75ce8594bcfc844dc159

Author: Saumen [email protected]

Date: Mon Apr 18 21:47:32 2022 -0600

day2.txt

commit ba8a9cac92a25d5e1ba35a41fb5121441cd1de27

Author: Saumen [email protected]

Date: Mon Apr 18 21:43:33 2022 -0600

Day1 data is added

C:\Users\pqplz947\Desktop\saumen>`

0

The commands you mentioned are working well on macOS. But On Windows, the caret symbol ^ is used as an escape character, which is why you encounter the "More?" prompt. If you are using Windows, the solution is to use the double caret symbol ^^ instead of ^. For Example:

git reset --soft HEAD^^  
git reset HEAD^^  
git reset --hard HEAD^^
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.