git - Rebase entire development branch onto new master branch -
i'm working repository in theory should following gitflow workflow (see a successful git branching model vincent driessen). however, initial commit on repository made on develop
branch , there no master
branch seen. it's nearing release time , need create master
branch reflects production-ready state of project should've been there start. keep in mind develop
branch has multiple feature branches coming off of it. repository entirely local , hasn't been pushed.
my idea create orphan branch master
, rebase develop
branch onto it, don't know how i'd go doing that.
so, how can create master
branch if created start?
update: in case, first commit on develop
not commit should considered suitable production, using initial master
commit unwise. reason project in state because not using vcs when decided use git.
after fiddling, came with. simpler, manual approach vonc's answer.
rebasing entire development branch
let's assume have branch develop
contains initial commit of repository, , you'd rewrite history such master
branch contains new initial commit instead.
first off, if inital commit on develop
branch suitable initial commit on new master
branch, can create master
branch there , you're done:
$ git branch master <sha1-of-initial-commit-on-develop>
if don't have luxury, you'll need create new empty commit serve initial commit of master
.
# create new master branch $ git checkout --orphan master # clear working directory (we want initial commit empty) $ git rm -rf . # create initial commit on master $ git commit --allow-empty -m "initial commit" # rebase entire develop branch onto new master branch $ git rebase --onto master --root develop
if there branches coming off of develop
branch, would've been "majorly messed up". because branches (we'll call them topic branches) still pointing old develop
branch before rebased. if had no branches coming off of develop
branch, you're done.
each topic branch going have rebased onto new develop
branch. this, we're going follow steps outlined in question (git: how rebase specific commit?). each topic branch, follow these steps.
replace <common-ancestor>
sha1 of commit on newly created develop
branch topic branch should branch off of.
$ git branch temp <common-ancestor> $ git checkout <topic-branch> $ git rebase temp $ git branch -d temp
and that's it! keep in mind should not rebase on branch you're collaborating on else.
Comments
Post a Comment