Search code examples
linuxgitxargsgit-squash

xargs (or something else) without space before parameter


I would like to execute something like this (git squash):

git rebase -i HEAD~3

extracting the 3 from git log:

git log | blabla | xargs git rebase -i HEAD~

This does not work because xargs inserts a space after HEAD~.

The problem is that I want to alias this command, so I cannot just use

git rebase -i HEAD~`git log | blabla`

because the number would be evaluated just when I define the alias.

I don't have to use xargs, I just need an alias (preferably not a function).


Solution

  • You can use the -I option of xargs:

    git log | blabla | xargs -I% git rebase -i HEAD~%