git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Brandon CaseyNext: Brandon Casey
Message 7 of 11 in “need to create new repository initially seeded with several branches”
  1. ryan@iridiumsuite.comAug 31, 2011
  2. in-git-vger@baka.orgAug 31, 2011
  3. Ryan WexlerAug 31, 2011
  4. in-git-vger@baka.orgAug 31, 2011
  5. Johannes SixtAug 31, 2011
  6. Brandon CaseyAug 31, 2011
  7. Jeff KingAug 31, 2011
  8. Brandon CaseyAug 31, 2011
  9. Ryan WexlerAug 31, 2011
  10. Brandon CaseyAug 31, 2011
  11. Brandon CaseyAug 31, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.