105

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.

danwellman
  • 9,068
  • 8
  • 60
  • 88
norbertas.gaulia
  • 2,033
  • 3
  • 18
  • 19
  • 17
    If you're using Windows, you could do `git log HEAD^^`, I believe. – Name McChange Nov 04 '13 at 00: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 '17 at 16:43
  • "git reset --soft HEAD^^" is what Windows wants. So the answer to the More? prompt is "^" – AndrewR Oct 06 '21 at 14:17

5 Answers5

101

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.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
54

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^"
Community
  • 1
  • 1
me_and
  • 15,158
  • 7
  • 59
  • 96
36

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.

mcdon
  • 4,931
  • 3
  • 38
  • 36
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 saumencs3j6@gmail.com

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

day2.txt

commit ba8a9cac92a25d5e1ba35a41fb5121441cd1de27

Author: Saumen saumencs3j6@gmail.com

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

Day1 data is added

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

Roy
  • 15
  • 2
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^^
LinFelix
  • 1,026
  • 1
  • 13
  • 23