git reset asks 'more?'
Asked Answered
B

5

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.

Bobsledding answered 7/1, 2013 at 21:1 Comment(3)
If you're using Windows, you could do git log HEAD^^, I believe.Kildare
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.Hartebeest
"git reset --soft HEAD^^" is what Windows wants. So the answer to the More? prompt is "^"Brunhild
H
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.

Haematozoon answered 7/1, 2013 at 21:27 Comment(3)
git log HEAD^ throws exactly same scenario, though git reset --soft HEAD~1 workaround works fineBobsledding
Thank you, workaround helps. More is asking no more.Moller
On Windows, where this is a problem, the simpler answer is that you need to quote the carret. Use "HEAD^" instead of HEAD^.Ridgeling
B
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^"
Bizerte answered 8/1, 2013 at 10:23 Comment(1)
This is quite common a problem :)Sidnee
S
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.

Standford answered 24/1, 2017 at 22:52 Comment(0)
C
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>`

Caftan answered 19/4, 2022 at 4:41 Comment(0)
R
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^^
Raffaello answered 6/8, 2023 at 7:13 Comment(1)
Solution already provided by this existing answer.Manslaughter

© 2022 - 2024 — McMap. All rights reserved.