Issue
I have a Git repository with two branches: master
and redesign
. The redesign
branch was created from master
, and master
has not been touched since then:
master
...|--m50--\
\--m51--|--m52--|--m53-- redesign
The redesign
branch has evolved so much that I would like to create a new whole repository from it, taking the first commit of redesign
as the initial commit of the new repository and forgetting the previous history inherited from master
:
master
...|--m50--
redesign
--r1--|--r2--|--r3--
Is this possible with Git? There is a related question to this, but its goal is to use a directory, not a branch.
Thanks!
Solution
You could:
- checkout the commit you want for the “root” of your new repo
- copy all the files to your new directory (except the
.git
directory) - check out your
redesign
branch git format-patch master..redesign
- move all the generated patch files somewhere handy
Then go to your new directory and:
$ git init
$ git add . # make sure your .gitignore is in place though
$ git commit -m"..."
$ git am /path/to/patches/*.patch
Answered By – Mat
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0