Ohmyzsh: zsh: no matches found: HEAD^

Created on 28 Jun 2011  ·  16Comments  ·  Source: ohmyzsh/ohmyzsh

When I run this git command, git reset --soft HEAD^ I get this back zsh: no matches found: HEAD^

I have these plugins in place plugins=(brew bundler git osx rails3 ruby textmate)

Most helpful comment

Escape the ^ in your command:

git reset --soft HEAD\^

All 16 comments

Escape the ^ in your command:

git reset --soft HEAD\^

Sweet. Thanks for the tip, that did it.

Yea, this is a problem in zshell. You can alternatively can use HEAD~ so that you don't have to escape it each time.

Actually, this problem is due to a setting in oh-my-zsh's bare bones configuration. It does not occur with plain old ZSH:

$ zsh -f 
ratham% echo HEAD^
HEAD^
ratham% 

So perhaps this issue should be reopened.

So I had this problem long before I started using oh-my-zsh.

Using the exact same setup as the OP (but without rvm installed):

davidd@hal9000 .dotfiles % g co HEAD^
M vim/bundle/vim-rails
M zsh/path.zsh
...

Here's zsh with simply rvm added:

davidd@hal9000 .dotfiles % zsh -f
hal9000% source "$HOME/.rvm/scripts/rvm"
hal9000% g co HEAD^
zsh: no matches found: HEAD^

Excellent find! Please report this on the RVM issue tracker as well.

I dug some more and found the real culprit:

# after loading RVM
$ unsetopt extendedglob
$ echo HEAD^
HEAD^

Ohhh, it looks like ^ filters out symbolic links in extendedglob. Ok, I think this working as intended then.

From man zshall:

^x (Requires EXTENDED_GLOB to be set.) Matches anything except the pattern x. This has a higher precedence than /', so^foo/bar' will search directories in .' except./foo' for a file named `bar'.

For people who are searching for a solution, another way to fix this is to setopt NO_NOMATCH, which passes the bad match onto the command.

Awesome tip! unsetopt nomatch FTW. :-)

@nickmeharry :heart_eyes:

Oh yeah thanks a lot for the tip @nickmeharry it helped for other issues as well, thx !

Yes this line fixed the issue.. thanks

Shouldn't this be the default behaviour ? took me some time to find the setopt NO_NOMATCH

sweet! @nickmeharry

Was this page helpful?
0 / 5 - 0 ratings