Reputation: 15996
I'm using Zsh and and trying to run git show for a project to see my revision history. If I do
git show HEAD
it works fine showing me my last commit, however the following commands don't work
[master↑5⚡]:~/project $ git show HEAD^
zsh: no matches found: HEAD^
[master↑5⚡]:~/project $ git show HEAD^^
zsh: no matches found: HEAD^^
However this does work
git HEAD~1
Am I doing something wrong here with git show HEAD^^
?
git version 1.7.4.5
Upvotes: 25
Views: 6719
Reputation: 44244
Instead of escaping or quoting the caret, you could just tell zsh
to stop bailing on the command when it fails to match a glob pattern. Put this option in your .zshrc
:
setopt NO_NOMATCH
That option stops zsh
from aborting commands if glob-matching fails. git show HEAD^
will work properly, and you needn't escape the caret. Furthermore, globbing and the ^
event designator will still work the way you expect.
To answer dolzenko's question in comments, you can get git log ^production master
(which is, coincidentally, also exactly what git's 'double dot' syntax does: git log production..master
) to work by disabling extended globbing:
setopt NO_EXTENDED_GLOB
Of course, you might actually rely on extended globbing and not know it. I recommend reading about what it does before disabling it.
Upvotes: 38
Reputation: 22596
You can also use noglob.
% noglob git show HEAD^
(or make an alias for noglob git
)
Upvotes: 9
Reputation: 141790
The carat (^
) has special meaning in Bash and Zsh.
You'll need to escape it or quote it:
% git show HEAD\^
% git show 'HEAD^^'
Upvotes: 33