Git feature branch dragged on too long

46 Views Asked by At

I've been committing locally to a feature branch for weeks. About a dozen commits ago, I should have pushed to master and merged, but didn't realize that until now. My log looks like

* ba3c9f0 (HEAD -> feature/v3.1.1) wakka wakka
* af5660e wakka wakka
* d3590b5 wakka wakka
* f7b1ad8 wakka wakka
* b37d62e wakka wakka
* f716242 wakka wakka
* adfd1cc wakka wakka
* fe7d61b wakka wakka
* d9a347c wakka wakka
* a1121c4 wakka wakka
* 133b607 wakka wakka
* e8c4651 final commit for v3.1.1.6
* 1a28184 wakka wakka
* 9c8187d wakka wakka
* d57a56d wakka wakka
* 1782297 wakka wakka
* 3437c50 wakka wakka
* c30e708 wakka wakka
* 1fb47ff final commit for v3.1.1.5

Everything from 133b607 to HEAD should have been committed to a new feature branch, created from the merged master, and e8c4651 should be the last entry in the "feature/v3.1.1" branch. I am completely solo on this application, so there are no other developers to synch with, and I have done nothing but commit locally --- no pushes or merges of any kind. Is there a simple way to correct this? I've searched for an answer, but sadly my google-fu is too weak to find this particular needle in the haystack of Git discussions.

All the commits are good --- I don't need to remove any of them --- and there is no concurrent development to worry about; I just should have made a new branch earlier. I haven't tried anything because it would just make things worse.

Thanks for your time.

1

There are 1 best solutions below

2
eftshift0 On

Assuming we are still working on feature/v3.1.1:

# set new branch at this commit
git branch some-new-branch
# set the new position of feature/v3.1.1 
git reset --hard e8c4651
# rebase commits in some-new-branch _past_ HEAD
# and set them on top of master
git rebase HEAD some-new-branch --onto master