Question

I created a git command that shows me the diff between the HEAD and the last Git-SVN commit.

Git is the command

git diff `git log --grep git-svn-id | grep commit | sed "s/commit //g" | head -1` HEAD

And I wanted to make an alias for it and I did it like this:

git config --global alias.diffsvn 'diff `git log --grep git-svn-id | grep commit | sed "s/commit //g" | head -1` HEAD'

but when I run git diffsvn and have the output of that command but I get

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

How can I make this alias work?

Was it helpful?

Solution

Short answer is you need to add a !git, in front of the diff, to tell git it is a shell command. So this:

git config --global alias.diffsvn '!git diff `git log --grep git-svn-id | grep commit | sed "s/commit //g" | head -1` HEAD'

I suggest this instead:

git config --global alias.diffsvn '!git diff `git log --grep git-svn-id -1 | sed -n "s/commit //p"` HEAD'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top