On a personal project that I am working on, I have the following situation -
N' <-- mainscreen
/
| N--O--P--Q <-- database
|/
A---B---C---D---------------------M <-- master
\ /
F--G--H--I--J--K--L <-- loginscreen
Now although I have some basic level of experience with git, I never knew about any good git practices nor have I ever worked on a big complex project before which has led my skills to stagnate. So I decided to learn it properly and follow some good practices with this project. A quick search led me to this which I guess is a popular model from all the references to it.
After going through the article, I realized that due to lack of planning in my commits, some of the code in the loginscreen branch is actually common code required in the other branches and should be kept separate. So I decided to rewrite the history of the branch so that the common code is separated out into a new develop branch. I found that interactive rebasing can be used to split the commits but I am not sure if that is possible here because I have already merged loginscreen into master (which was probably a bad idea). Basically what I want to do is -
- Create a new branch
developbased on A, the initial commit - Move B, C, D commits to develop
- Split F - L commits such that only the code related to
loginscreenis in its own branch and the common code is indevelop - Merge
loginscreenintodevelop - If possible, remove the merge commit M in master
- Rebase the
databaseandmainscreenbranches on the newdevelopbranch
The result should be something like this -
A-----------------------M----------- <-- master
\ | N--O--P--Q <-- database
\ |/
B---C---D---G--I--K--L <-- develop
\ / \
F---H---J \ <-- loginscreen
\
N` <-- mainscreen
(G, I, K commits contain the common code)
Like I said, this is a personal project and hasn't been pushed yet so there will be no issues in rewriting the history. But is this even possible?