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.

2
  • 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 #? Commented Oct 26, 2018 at 20:06
  • @omajid That doesn't work. It seems like the develop argument is double counted. Commented Oct 26, 2018 at 20:19

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.