I’ve recently switched to Git from CVS/SVN and so far enjoying it. However, in my latest dev cycle, I forgot a critical step in creating a master branch before creating my dev branch.
In my normal cycle, I have my trunk (stable code), and then my maintenance branch in which we perform maintenance releases. Within that maintenance branch, we have our dev branches for individual bugs.
Usually, my maintenance branch follows my versions. So in my trunk I’ll have my Major versions (ie: ver 1, ver 2, ver 3). Then my maintenance branch (ie: 1.1, 2.1, 2.2, etc). Then within my maintenance branch, my dev branch for this release (ie: 1.2.1, 2.1.3, etc).
In my last cycle, I was working on 2.2.1. My last release was 2.1.8. I accidentally branched from my 2.1 branch and did work on it, instead of first creating a 2.2 branch. Now, when I want to merge my changes back, I don’t have a 2.2 branch to merge back into.
What I “should” have done was merge my 2.1 branch back into the trunk (v2) and then branched 2.2 from the trunk and then 2.2.1 from the 2.2 branch.
Now that I do not have a 2.2 branch and my 2.2.1 branch incorrectly comes off 2.1, how do I save myself?
There has been a lot of dev work done in 2.2.1 already.
|-1.0
|-2.0
|-2.1
|-2.1.1
|-2.1.2
|-....
|-2.1.8
|-2.2.1 <---- wrong place!!!
Should have been:
|-1.0
|-2.0
|-2.1
|-2.1.1
|-2.1.2
|-....
|-2.1.8
|-2.2
|-2.2.1
Thanks,
Eric
First off, in git you can always change things later and move things around. So don’t panic. First, create a copy of your entire directory to run the tests on a different copy “just in case” before doing it on your main copy. It’ll make you feel a bit safer.
What you need to do is:
1) create the 2.2 branch where you want it to be. IE, check out where you should have branched from (something like
git checkout v2.1I think, but it’s hard to tell from your description). Then create the 2.2 branch there with something likegit checkout -b v2.2.2) Then, you need to move your 2.2.1 branch over to the v2.2 branch. This is actually fairly easily done with
git rebase, which functionally moves a branch from one spot in a tree to another. You’d do this withgit checkout v2.2.1followed bygit rebase v2.2, which will move the changes made in the v2.2.1 branch over into the new v2.2 branch.