Was working on a feature just now and noticed that I had forgotten to add a service that I thought was committed 2 commits ago. No problem, right? just
git rebase -i that sucker and put them into that commit!
$ git rebase -i <three refs ago>
OK. So I want to
edit the commit from 2 refs ago and leave the last commit alone.
pick: <last commit> edit: <target commit>
I save... and now I can go in and add my files.
git add src/app/services/ git commit --amend
It is at this point that I want to note that I actually have been playing around with using
zsh's git plugin, which offers two aliases that are relevant to rebases:
git rebase --abort
git rebase --continue
Also, what ended up happening at this point was this:
My commit was aborted, and those files that were amended to the rebased commit? Gone.
Thankfully PHPStorm's local history saved my code. Although in this particular case the service was all of 10 lines... but next time I shall have to be more careful when doing interactive rebases!
Update: See in comments below. The
reflog held the data! It was not gone...