rebase - Reorganising git commits into different branches -


i trying reorganise git tree structured bit better. @ moment have single master branch couple of small feature branches split it. want go , reorder commits in main branch ones corresponding new version numbers , have in between commits reside in separate develop branch feature branches split too. i'm looking tool let me manually reorganise tree. thought maybe interactive rebasing looking trying in sourcetree makes seem not right tool.

can give me advice on how best proceed. below diagram of current structure:

featurea                       x-x-x                                  /     \ master     a-x-x-x-x-b-x-x-x-c       d 

desired structure:

feature                   x-x-x                          /    | develop     x-x-x-x-x-x-x    -            /      |     |     | master       -  b  -  c  -  d 

having linear history -like current structure- wanted many people. if want try new workflow, adopting on, without changing past? save trouble.

however, if want change it, do:

#start put tags on 'main' commits, ease manipulations git checkout b git tag tagb git checkout b git tag tagb git checkout d git tag tagd  #start rewrite oldest #not do: need add merge commit git checkout git merge --no-ff b git branch -f master  #continue c #same thing, need cherry-pick intermediate commits git checkout tagb git cherry-pick c~3 git cherry-pick c~2 git cherry-pick c~1 git cherry-pick c git merge --no-ff master git branch -f master  #continue d ... 

to ease manipulations , ensure know going on, should open gitk --all head in background, , regularly press f5 refresh it.

and if think messed up, , want retrieve initial state, you'd need do

git checkout tagd git branch -f master 

a final word: if shared commits (eg: if pushed), should warn have them, you're going change structure of history. otherwise lead real mess.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -