I have two branches, master and feature.
I finished working on feature, so this branch have a lot of commits, but I don’t want to publish it as is. I want to create a branch called feature_clean with all the modifications from feature but with better commits.
I tried the following:
git checkout -b feature_clean master
git checkout feature
git rebase --interactive feature_clean
# reorganize commits etc, save and close editor
, and this created feature_clean correctly BUT it also modified feature. In fact, both branches were equal.
What did I do wrong? I want to keep feature as is for now (I’ll delete it later, after feature_clean is appropriately tested and approved).
you have your rebase command wrong 😉 you are telling git to rebase the current branch (
HEAD, in that casefeature) on top offeature_clean. I think what you actually want to do is:i.e. replay commits from
feature_cleanonmaster.featurewill still point to the old commits.git rebase masteris shorthand forgit rebase --onto master master HEAD: take all commits betweenmasterandHEAD(reachable fromHEAD, but not frommaster) and stick them ontomaster