I am not, and will never be, a git
expert, so kindly be gentle.
I have a PR branch which has—Github tells me—let's say 12 commits on it.
While I've been working on this PR, I've merged master
(the branch it diverged from originally) into it a couple of times. I am planning on squashing all commits down to one before this PR is accepted and merged.
I know that I am going to use git rebase -i
to do this. The general area of this question is how to come up with the argument to supply to this command.
Given the merges from master
to my PR branch etc. etc., git merge-base
doesn't give me, I don't think, the right SHA to supply as an argument to git rebase -i
. It will, in fact, give me the most recent commit that "came over" from master
, instead of the earliest point at which my branch "started".
I have, of course, read this excellent answer. Its "shell magic" answer works, but I don't fully understand it, and I don't like relying on magic I don't understand.
My question, therefore, is: From my PR branch, can I, instead, use this comparatively simple command: git rebase -i HEAD~12
, where 12
is whatever Github tells me is the number of commits on my branch?
(I am assuming in all of this, of course, that I have push
ed my local branch to my origin
, i.e. my local on-my-laptop branch is identical to my Github-hosted origin
branch. Implicit in this assumption is that if Github says 12 commits, then my on-my-laptop branch should also have exactly 12 commits.)
Is this number of commits OK to supply after the tilde (~
)? Is this a reliable, relatively brain-dead-easy thing to do? Or will I trip myself up on yet another inscrutable git
option or convention?