I created a “feature” branch off master and worked for a long while. I then fetched the latest master branch commits and rebased my “feature” branch commits on top of it. Then I merged “feature” into master. However, I forgot about the merge and continued committing into the “feature” branch. I want those commits in a new branch now, so I would now like to create another branch, “feature_2”, that is based on the commits on the “feature” branch since the last merge into master. Any suggestions?
Share
Considering that:
featurealready references commits since last merge intomasterx--x--x (master) \ y--y--y (feature), you can simply:
git checkout featuregit checkout -b feature2git branch -f feature master(provided no commits were made on
mastersince thefeaturemerge)x--x--x (master, feature) \ y--y--y (feature2)All the commits from master are no longer referenced by
feature(which is reset to wheremasteris), but are now accessible throughfeature2(which is wherefeatureis before being reset tomaster)The OP Chip Castle adds:
So the situation is:
x--x--x--y'--y' (master, updated after a fetch from other repo) \ y'--y'--y--y (feature, with y' being already merged, and y being the commits I need)Then you can simply rebase feature on top of master: identical commits will be ignored.