Re: need to create new repository initially seeded with several branches
- From
Jeff King <peff@peff.net>
- Date
- Aug 31, 2011, 16:54 UTC
- Message-ID
- <20110831165405.GB4356@sigill.intra.peff.net>
- In-Reply-To
- <sDZ5pnWzh3ZbFYS6GK-NcPdn09kF53MJ2eRkBnzInzdL8-cvCiF5beUw2k9Pz6BTq-Y3i_XwpYfgTOvXNlP1vPjLSHJ6FIzxL0jN1W0d0M8@cipher.nrlssc.navy.mil>
On Wed, Aug 31, 2011 at 11:14:48AM -0500, Brandon Casey wrote:
Show 13 quoted lines
> git checkout -b devel && # make a new branch named "devel" > # which has the same state as the > # currently checked out branch: "master" > # i.e. devel and master point to the > # same tip commit. > rm -rf * && # remove the files in the working dir > cp -a $devel_dir/* . && # cp devel source code to working dir > git add -A . && # add new/removed files to the index > # to be committed on next 'git commit' > git commit > # use editor to give descriptive commit message > > Repeat for your topic branch based off of devel.
I am probably just going to confuse the original poster more, but here is how I would do it. It's slightly more efficient, as it doesn't involve removing and copying files for the intermediate states:
# make a repo and switch to it git init repo && cd repo
# and now add everything from the "master" version, and # make a commit out of it GIT_WORK_TREE=/path/to/master git add -A git commit
# now make the devel branch and do the same git checkout -b devel GIT_WORK_TREE=/path/to/devel git add -A git commit
# and then check out the result in the working tree of # your newly created repo git checkout -f
-Peff