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
Iin-git-vger@baka.org <in-git-vger@baka.org>
Date
Aug 31, 2011, 15:40 UTC
Message-ID
<201108311540.p7VFen5S015756@no.baka.org>
In-Reply-To
<1314804325568-6746957.post@n2.nabble.com>
In message <1314804325568-6746957.post@n2.nabble.com>, "ryan@iridiumsuite.com" writes:
    I would like to turn this into a git repository.  One branch being master,
    the second develop and finally a third branch that is extended off the
    develop branch.
I will assume in my instructions that develop is "extended" off of master.

---------------------------------------------------------------------- cd /path/to/new/master # Make this a git repo git init # Add all files to git git add . # Commit all files to git git commit -m "initial master version" # Make new develop branch git checkout -b develop # Cause git to delete all files in the internal index git read-tree --reset -i 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Cause git to delete all files in the working directory git clean -dfx # Copy all files from the develop directory cp -r /path/to/new/develop . # Add all files to git (and delete them too) git add -A . # Commit git commit -m "Initial develop branch" # Make new extended branch git checkout -b extended # Cause git to delete all files in the internal index git read-tree --reset -i 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Cause git to delete all files in the working directory git clean -dfx # Copy all files from the extended directory cp -r /path/to/new/extended . # Add all files to git (and delete them too) git add -A . # Commit git commit -m "Initial develop branch" ----------------------------------------------------------------------

The only "magic" is the read-tree/git-clean stuff. The 4b82… value is the SHA of an empty tree. It could be replaced by a:

find . -maxdepth 1 ! -name '.git' -a ! -name '..' -a ! -name '.' -print0 | xargs -0 rm -rf
But that is 9 extra characters.
Untested, but it should work.
					-Seth Robertson
Previous: ryan@iridiumsuite.comNext: Ryan Wexler
Message 2 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.