0

I am trying to make a git alias to rebase onto the common ancestor of another branch. So that I can type...

git rbca develop -i

and it gets expanded to...

git rebase $(git merge-base HEAD develop) -i

Here is what I have:

rbca = "!git rebase $(git merge-base HEAD $1) #"

I'm very close. They only problem is that the # doesn't work as expected so the -i has no effect.

Here are the other SO answers that have gotten me this far.

cambunctious
  • 8,391
  • 5
  • 34
  • 53
  • 1
    The second question you linked to says "The final # is important - it prevents all the user-supplied arguments from being processed by the shell (it comments them out)". So.. it sounds like you want to leave off the final `#`? – omajid Oct 26 '18 at 20:06
  • @omajid That doesn't work. It seems like the develop argument is double counted. – cambunctious Oct 26 '18 at 20:19

1 Answers1

0

I got it. I need to add arguments 2 and after using ${@:2} and still use # to prevent arguments from being added again.

rbca = "!git rebase $(git merge-base HEAD \"$1\") ${@:2} #"

Credit: https://stackoverflow.com/a/3995365/2019549

cambunctious
  • 8,391
  • 5
  • 34
  • 53