I am trying to add a git alias that makes me abort a rebase that have just finished. I tried to add this in .gitconfig
:
rebabort = !sh -c 'git reflog | grep -v rebase | head -1 | sed -e "s/^\([[:alnum:]][[:alnum:]]*\)\(.*\)/\1/g" | git reset --hard'
but it complains about a wrong configuration. Anyway I tried to add the alias in the following way:
git config alias.rebabort '!git reflog | grep -v rebase | head -1 | sed -e "s/^\([[:alnum:]][[:alnum:]]*\)\(.*\)/\1/g" | git reset --hard'
and it worked. What am I missing?
UPDATE
I also tried to add this in .gitconfig
rebabort = "!f() { \
git reflog | grep -v rebase | head -1 | sed -e 's/^\([[:alnum:]][[:alnum:]]*\)\(.*\)/\1/g\' | git reset --hard;
}; f"
and this
rebabort = !"git reflog | grep -v rebase | head -1 | sed -e 's/^\([[:alnum:]][[:alnum:]]*\)\(.*\)/\1/g' | git reset --hard"
but it still complains about wrong configuration.