{"thread":{"id":"28268","subject":"need to create new repository initially seeded with several branches","startedAt":"2011-08-31T15:25:25Z","lastAt":"2011-08-31T17:48:08Z","messageCount":11,"participants":["ryan@iridiumsuite.com","Ryan Wexler","Brandon Casey","in-git-vger@baka.org","Jeff King","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"174614","messageId":"1314804325568-6746957.post@n2.nabble.com","threadId":"28268","inReplyTo":null,"subject":"need to create new repository initially seeded with several branches","fromName":"ryan@iridiumsuite.com","fromEmail":"ryan@iridiumsuite.com","sentAt":"2011-08-31T15:25:25Z","receivedAt":"2011-08-31T15:25:25Z","isPatch":false,"sender":{"key":"ryan@iridiumsuite.com","avatar":null},"body":"Noobie here...Don't ask why, but I have essentially 3 branches in separate\ncode bases on my file system that aren't in a repository right now.  \n\nI would like to turn this into a git repository.  One branch being master,\nthe second develop and finally a third branch that is extended off the\ndevelop branch.\n\nIs there a way to do this?  Could someone give me a step by step?  I am\nhaving a hard enough time just getting use to git and I am lost trying to\nfigure this out.\n\nthanks so much\n\n--\nView this message in context: http://git.661346.n2.nabble.com/need-to-create-new-repository-initially-seeded-with-several-branches-tp6746957p6746957.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"174618","messageId":"201108311540.p7VFen5S015756@no.baka.org","threadId":"28268","inReplyTo":"1314804325568-6746957.post@n2.nabble.com","subject":"Re: need to create new repository initially seeded with several branches","fromName":"","fromEmail":"in-git-vger@baka.org","sentAt":"2011-08-31T15:40:49Z","receivedAt":"2011-08-31T15:40:49Z","isPatch":false,"sender":{"key":"in-git-vger@baka.org","avatar":null},"body":"\nIn message <1314804325568-6746957.post@n2.nabble.com>, \"ryan@iridiumsuite.com\" writes:\n\n    I would like to turn this into a git repository.  One branch being master,\n    the second develop and finally a third branch that is extended off the\n    develop branch.\n\nI will assume in my instructions that develop is \"extended\" off of master.\n\n----------------------------------------------------------------------\ncd /path/to/new/master\n# Make this a git repo\ngit init\n# Add all files to git\ngit add .\n# Commit all files to git\ngit commit -m \"initial master version\"\n# Make new develop branch\ngit checkout -b develop\n# Cause git to delete all files in the internal index\ngit read-tree --reset -i 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n# Cause git to delete all files in the working directory\ngit clean -dfx\n# Copy all files from the develop directory\ncp -r /path/to/new/develop .\n# Add all files to git (and delete them too)\ngit add -A .\n# Commit\ngit commit -m \"Initial develop branch\"\n# Make new extended branch\ngit checkout -b extended\n# Cause git to delete all files in the internal index\ngit read-tree --reset -i 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n# Cause git to delete all files in the working directory\ngit clean -dfx\n# Copy all files from the extended directory\ncp -r /path/to/new/extended .\n# Add all files to git (and delete them too)\ngit add -A .\n# Commit\ngit commit -m \"Initial develop branch\"\n----------------------------------------------------------------------\n\nThe only \"magic\" is the read-tree/git-clean stuff.  The 4b82â¦ value is\nthe SHA of an empty tree.  It could be replaced by a:\n\nfind . -maxdepth 1 ! -name '.git' -a ! -name '..' -a ! -name '.' -print0 | xargs -0 rm -rf\n\nBut that is 9 extra characters.\n\nUntested, but it should work.\n\n\t\t\t\t\t-Seth Robertson\n"},{"id":"174615","messageId":"CAKjsY4nsPNO_kvxeime8qcNrRFykgG2TOYxJ0HKbj2zR5Rwv+Q@mail.gmail.com","threadId":"28268","inReplyTo":"201108311540.p7VFen5S015756@no.baka.org","subject":"Re: need to create new repository initially seeded with several branches","fromName":"Ryan Wexler","fromEmail":"ryan@iridiumsuite.com","sentAt":"2011-08-31T16:10:01Z","receivedAt":"2011-08-31T16:10:01Z","isPatch":false,"sender":{"key":"ryan@iridiumsuite.com","avatar":null},"body":"On Wed, Aug 31, 2011 at 8:40 AM,  <in-git-vger@baka.org> wrote:\n>\n> In message <1314804325568-6746957.post@n2.nabble.com>, \"ryan@iridiumsuite.com\" writes:\n>\n>    I would like to turn this into a git repository.  One branch being master,\n>    the second develop and finally a third branch that is extended off the\n>    develop branch.\n>\n> I will assume in my instructions that develop is \"extended\" off of master.\n>\n> ----------------------------------------------------------------------\n> cd /path/to/new/master\n> # Make this a git repo\n> git init\n> # Add all files to git\n> git add .\n> # Commit all files to git\n> git commit -m \"initial master version\"\n> # Make new develop branch\n> git checkout -b develop\n> # Cause git to delete all files in the internal index\n> git read-tree --reset -i 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n> # Cause git to delete all files in the working directory\n> git clean -dfx\n> # Copy all files from the develop directory\n> cp -r /path/to/new/develop .\n> # Add all files to git (and delete them too)\n> git add -A .\n> # Commit\n> git commit -m \"Initial develop branch\"\n> # Make new extended branch\n> git checkout -b extended\n> # Cause git to delete all files in the internal index\n> git read-tree --reset -i 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n> # Cause git to delete all files in the working directory\n> git clean -dfx\n> # Copy all files from the extended directory\n> cp -r /path/to/new/extended .\n> # Add all files to git (and delete them too)\n> git add -A .\n> # Commit\n> git commit -m \"Initial develop branch\"\n> ----------------------------------------------------------------------\n>\n> The only \"magic\" is the read-tree/git-clean stuff.  The 4b82… value is\n> the SHA of an empty tree.  It could be replaced by a:\n>\n> find . -maxdepth 1 ! -name '.git' -a ! -name '..' -a ! -name '.' -print0 | xargs -0 rm -rf\n>\n> But that is 9 extra characters.\n>\n> Untested, but it should work.\n>\n>                                        -Seth Robertson\n>\n\nSeth-\nThanks for the extensive reply.  I am excited that this is even possible.\n\nI have to say that I am lost by the \"magic\" you describe.  I don't\nunderstand what you mean by the 4b82... value should be replaced by\nthe find | xargs remove all command.   That command looks like it just\ndeletes all the \".\" file names?  But when you say replace I thought\nyou would mean I need to generate a new value to replace that magic\nnumber??  Confused...\n"},{"id":"174616","messageId":"sDZ5pnWzh3ZbFYS6GK-NcPdn09kF53MJ2eRkBnzInzdL8-cvCiF5beUw2k9Pz6BTq-Y3i_XwpYfgTOvXNlP1vPjLSHJ6FIzxL0jN1W0d0M8@cipher.nrlssc.navy.mil","threadId":"28268","inReplyTo":"1314804325568-6746957.post@n2.nabble.com","subject":"Re: need to create new repository initially seeded with several branches","fromName":"Brandon Casey","fromEmail":"brandon.casey.ctr@nrlssc.navy.mil","sentAt":"2011-08-31T16:14:48Z","receivedAt":"2011-08-31T16:14:48Z","isPatch":false,"sender":{"key":"brandon.casey.ctr@nrlssc.navy.mil","avatar":null},"body":"On 08/31/2011 10:25 AM, ryan@iridiumsuite.com wrote:\n> Noobie here...Don't ask why, but I have essentially 3 branches in separate\n> code bases on my file system that aren't in a repository right now.  \n> \n> I would like to turn this into a git repository.  One branch being master,\n> the second develop and finally a third branch that is extended off the\n> develop branch.\n> \n> Is there a way to do this?  Could someone give me a step by step?  I am\n> having a hard enough time just getting use to git and I am lost trying to\n> figure this out.\n\nSo, you want your repository and dag to look like this:\n\n     *------*------*\n     |      |      |\n  master  devel  topic\n\nbut it may help you visualize it to write it like this:\n\n  master *\n          \\\n     devel *\n            \\\n       topic *\n\nJust be aware that the above two are the same.  If you don't understand\nthat now, then let this plant the seed in your brain of the concept that\nbranches are merely \"pointers\" to a state of your repository.  Don't\nworry, you don't have to understand that now in order to get started\nand accomplish what you are trying to do...\n\nFirst, create your git repository based on the code in the directory\nholding what you would like to become the master branch.\n\nEither\n\n   cd $path_to_master_code\n\nor\n\n   mkdir $my_new_project_directory &&\n   cd $my_new_project_directory &&\n   cp -a $path_to_master_code/* .\n\nthen\n\n   git init &&\n   git add . &&\n   git commit -m 'Initial import into git'\n\nVoila, you have your master branch.  Now just create your devel\nbranch and copy your devel code into it and commit.\n\n   git checkout -b devel &&  # make a new branch named \"devel\"\n                             # which has the same state as the\n                             # currently checked out branch: \"master\"\n                             # i.e. devel and master point to the\n                             # same tip commit.\n   rm -rf * &&               # remove the files in the working dir\n   cp -a $devel_dir/* . &&   # cp devel source code to working dir\n   git add -A . &&           # add new/removed files to the index\n                             # to be committed on next 'git commit'\n   git commit\n   # use editor to give descriptive commit message\n\nRepeat for your topic branch based off of devel.\n\nPlease make sure you read the man pages for the above commands and\nunderstand what is going on before you do it, and double-check my\ncommands.\n\n-Brandon\n"},{"id":"174617","messageId":"201108311621.p7VGLDlm015261@no.baka.org","threadId":"28268","inReplyTo":"CAKjsY4nsPNO_kvxeime8qcNrRFykgG2TOYxJ0HKbj2zR5Rwv+Q@mail.gmail.com","subject":"Re: need to create new repository initially seeded with several branches","fromName":"","fromEmail":"in-git-vger@baka.org","sentAt":"2011-08-31T16:21:13Z","receivedAt":"2011-08-31T16:21:13Z","isPatch":false,"sender":{"key":"in-git-vger@baka.org","avatar":null},"body":"\nIn message <CAKjsY4nsPNO_kvxeime8qcNrRFykgG2TOYxJ0HKbj2zR5Rwv+Q@mail.gmail.com>, Ryan Wexler writes:\n\n    > # Cause git to delete all files in the internal index\n    > git read-tree --reset -i 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n    > # Cause git to delete all files in the working directory\n    > git clean -dfx\n\n    > The only \"magic\" is the read-tree/git-clean stuff.  The 4b82\n    > value is the SHA of an empty tree.  It could be replaced by\n    > a:\n    >\n    > find . -maxdepth 1 ! -name '.git' -a ! -name '..' -a ! -name '.' -print0 | xargs -0 rm -rf\n\n    I have to say that I am lost by the \"magic\" you describe.  I don't\n    understand what you mean by the 4b82... value should be replaced by\n    the find | xargs remove all command.   That command looks like it just\n    deletes all the \".\" file names?  But when you say replace I thought\n    you would mean I need to generate a new value to replace that magic\n    number??  Confused...\n\nI was just trying to explain what the git-read-tree and git-clean\ncommands are doing.  The long string starting with 4b825d is a special\nSHA that git knows represents an empty tree.  I was saying that you\n*could* (not should) replace the two commands (git-read-tree and\ngit-clean) with the \"find | xargs rm\" command I quoted.  The two sets\nof commands are equivalent.\n\nAlso, if you look at the find command, I am finding everything\n*except* the .git . and .. directories\n\n\t\t\t\t\t-Seth Robertson\n"},{"id":"174622","messageId":"yOArP4qOaF5Yee5Bgcafl_795D9Xnz_IaUH21_GToggoTEy0uLzpGd3OA-rFJt2MlFFYbhvSBNDlv5C_GjSvXfcw7SRn4Ut12giha2cV4yM@cipher.nrlssc.navy.mil","threadId":"28268","inReplyTo":"201108311624.p7VGOWWq018472@no.baka.org","subject":"Re: Re: need to create new repository initially seeded with several branches","fromName":"Brandon Casey","fromEmail":"brandon.casey.ctr@nrlssc.navy.mil","sentAt":"2011-08-31T16:45:02Z","receivedAt":"2011-08-31T16:45:02Z","isPatch":false,"sender":{"key":"brandon.casey.ctr@nrlssc.navy.mil","avatar":null},"body":"On 08/31/2011 11:24 AM, in-git-vger@baka.org wrote:\n> \n> In message <sDZ5pnWzh3ZbFYS6GK-NcPdn09kF53MJ2eRkBnzInzdL8-cvCiF5beUw2k9Pz6BTq-Y3i_XwpYfgTOvXNlP1vPjLSHJ6FIzxL0jN1W0d0M8@cipher.nrlssc.navy.mil>, Brandon Casey writes:\n> \n>        rm -rf * &&               # remove the files in the working dir\n> \n> I just note (for your information only) that this doesn't get rid of\n> any . files which might exist.  That is the advantage of the\n> git-read-tree;git-clean or the `find | xargs rm` alternatives I\n> mentioned in my post.  99% of the time it doesn't matter of course,\n> since it would only fail on . files which were deleted in the data\n> stream you were replacing.\n\nI was just crafting a reply to your message to say the same thing.\n\nNote also that the dot files would not have been copied into the\nworking directory in the first place, using a command like this:\n\n   cp -a /some/path/* .\n\nSo, Ryan, if your project contains dot files that you would want\nto track, take care that they are actually copied and deleted\nwith the other files while you are creating your repository.\n\n-Brandon\n"},{"id":"174626","messageId":"20110831165405.GB4356@sigill.intra.peff.net","threadId":"28268","inReplyTo":"sDZ5pnWzh3ZbFYS6GK-NcPdn09kF53MJ2eRkBnzInzdL8-cvCiF5beUw2k9Pz6BTq-Y3i_XwpYfgTOvXNlP1vPjLSHJ6FIzxL0jN1W0d0M8@cipher.nrlssc.navy.mil","subject":"Re: need to create new repository initially seeded with several branches","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-08-31T16:54:05Z","receivedAt":"2011-08-31T16:54:05Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 31, 2011 at 11:14:48AM -0500, Brandon Casey wrote:\n\n>    git checkout -b devel &&  # make a new branch named \"devel\"\n>                              # which has the same state as the\n>                              # currently checked out branch: \"master\"\n>                              # i.e. devel and master point to the\n>                              # same tip commit.\n>    rm -rf * &&               # remove the files in the working dir\n>    cp -a $devel_dir/* . &&   # cp devel source code to working dir\n>    git add -A . &&           # add new/removed files to the index\n>                              # to be committed on next 'git commit'\n>    git commit\n>    # use editor to give descriptive commit message\n> \n> Repeat for your topic branch based off of devel.\n\nI am probably just going to confuse the original poster more, but here\nis how I would do it. It's slightly more efficient, as it doesn't\ninvolve removing and copying files for the intermediate states:\n\n  # make a repo and switch to it\n  git init repo && cd repo\n\n  # and now add everything from the \"master\" version, and\n  # make a commit out of it\n  GIT_WORK_TREE=/path/to/master git add -A\n  git commit\n\n  # now make the devel branch and do the same\n  git checkout -b devel\n  GIT_WORK_TREE=/path/to/devel git add -A\n  git commit\n\n  # and then check out the result in the working tree of\n  # your newly created repo\n  git checkout -f\n\n-Peff\n"},{"id":"174627","messageId":"b0jgmOi0Ah4tb2fbieP8wOLjAFkigcbyvh9ajtwoMITJ_sDaDBsfMmEh6_jv25UG4WpHCnhlXi0IFpVlkK9KuEOzDLz2r_l4pBt97stEDXg@cipher.nrlssc.navy.mil","threadId":"28268","inReplyTo":"yOArP4qOaF5Yee5Bgcafl_795D9Xnz_IaUH21_GToggoTEy0uLzpGd3OA-rFJt2MlFFYbhvSBNDlv5C_GjSvXfcw7SRn4Ut12giha2cV4yM@cipher.nrlssc.navy.mil","subject":"Re: Re: need to create new repository initially seeded with several branches","fromName":"Brandon Casey","fromEmail":"brandon.casey.ctr@nrlssc.navy.mil","sentAt":"2011-08-31T16:54:43Z","receivedAt":"2011-08-31T16:54:43Z","isPatch":false,"sender":{"key":"brandon.casey.ctr@nrlssc.navy.mil","avatar":null},"body":"\n@Seth Robertson\n\nYour email address seems to be broken.  My message to you bounced:\n\n   ----- The following addresses had permanent fatal errors -----\n<in-git-vger@baka.org>\n    (reason: 550 5.1.1 <in-git-vger@baka.org>... User unknown)\n\n   ----- Transcript of session follows -----\n... while talking to tsutomu.baka.org.:\n>>> >>> DATA\n<<< 550 5.1.1 <in-git-vger@baka.org>... User unknown\n550 5.1.1 <in-git-vger@baka.org>... User unknown\n<<< 503 5.0.0 Need RCPT (recipient)\n\n   ----- Original message follows -----\n<snip>\n"},{"id":"174630","messageId":"XWAITZ7y0RejBGQezy-miO4ykUsgbNWA0mNtHRto22msjs3PP6WSZlN-pPueaz0duxAP6dCio3ZH2lna0K_g79NKdL0q7sJbzjj8sEKicYM@cipher.nrlssc.navy.mil","threadId":"28268","inReplyTo":"20110831165405.GB4356@sigill.intra.peff.net","subject":"Re: need to create new repository initially seeded with several branches","fromName":"Brandon Casey","fromEmail":"brandon.casey.ctr@nrlssc.navy.mil","sentAt":"2011-08-31T17:01:57Z","receivedAt":"2011-08-31T17:01:57Z","isPatch":false,"sender":{"key":"brandon.casey.ctr@nrlssc.navy.mil","avatar":null},"body":"On 08/31/2011 11:54 AM, Jeff King wrote:\n> On Wed, Aug 31, 2011 at 11:14:48AM -0500, Brandon Casey wrote:\n> \n>>    git checkout -b devel &&  # make a new branch named \"devel\"\n>>                              # which has the same state as the\n>>                              # currently checked out branch: \"master\"\n>>                              # i.e. devel and master point to the\n>>                              # same tip commit.\n>>    rm -rf * &&               # remove the files in the working dir\n>>    cp -a $devel_dir/* . &&   # cp devel source code to working dir\n>>    git add -A . &&           # add new/removed files to the index\n>>                              # to be committed on next 'git commit'\n>>    git commit\n>>    # use editor to give descriptive commit message\n>>\n>> Repeat for your topic branch based off of devel.\n> \n> I am probably just going to confuse the original poster more, but here\n> is how I would do it. It's slightly more efficient, as it doesn't\n> involve removing and copying files for the intermediate states:\n> \n>   # make a repo and switch to it\n>   git init repo && cd repo\n> \n>   # and now add everything from the \"master\" version, and\n>   # make a commit out of it\n>   GIT_WORK_TREE=/path/to/master git add -A\n>   git commit\n> \n>   # now make the devel branch and do the same\n>   git checkout -b devel\n>   GIT_WORK_TREE=/path/to/devel git add -A\n>   git commit\n> \n>   # and then check out the result in the working tree of\n>   # your newly created repo\n>   git checkout -f\n\nBetter.\n\n-Brandon\n"},{"id":"174635","messageId":"CAKjsY4kYm4ixTVQE4+8XZrf7DkAfn=ASoeMYob=5i1FmJ6eK5w@mail.gmail.com","threadId":"28268","inReplyTo":"XWAITZ7y0RejBGQezy-miO4ykUsgbNWA0mNtHRto22msjs3PP6WSZlN-pPueaz0duxAP6dCio3ZH2lna0K_g79NKdL0q7sJbzjj8sEKicYM@cipher.nrlssc.navy.mil","subject":"Re: need to create new repository initially seeded with several branches","fromName":"Ryan Wexler","fromEmail":"ryan@iridiumsuite.com","sentAt":"2011-08-31T17:09:12Z","receivedAt":"2011-08-31T17:09:12Z","isPatch":false,"sender":{"key":"ryan@iridiumsuite.com","avatar":null},"body":"Ok thanks for all the replies guys.  I thought I was SOL.  I will\nstart playing with it here and let you know how it goes.\n\nOn Wed, Aug 31, 2011 at 10:01 AM, Brandon Casey\n<brandon.casey.ctr@nrlssc.navy.mil> wrote:\n> On 08/31/2011 11:54 AM, Jeff King wrote:\n>> On Wed, Aug 31, 2011 at 11:14:48AM -0500, Brandon Casey wrote:\n>>\n>>>    git checkout -b devel &&  # make a new branch named \"devel\"\n>>>                              # which has the same state as the\n>>>                              # currently checked out branch: \"master\"\n>>>                              # i.e. devel and master point to the\n>>>                              # same tip commit.\n>>>    rm -rf * &&               # remove the files in the working dir\n>>>    cp -a $devel_dir/* . &&   # cp devel source code to working dir\n>>>    git add -A . &&           # add new/removed files to the index\n>>>                              # to be committed on next 'git commit'\n>>>    git commit\n>>>    # use editor to give descriptive commit message\n>>>\n>>> Repeat for your topic branch based off of devel.\n>>\n>> I am probably just going to confuse the original poster more, but here\n>> is how I would do it. It's slightly more efficient, as it doesn't\n>> involve removing and copying files for the intermediate states:\n>>\n>>   # make a repo and switch to it\n>>   git init repo && cd repo\n>>\n>>   # and now add everything from the \"master\" version, and\n>>   # make a commit out of it\n>>   GIT_WORK_TREE=/path/to/master git add -A\n>>   git commit\n>>\n>>   # now make the devel branch and do the same\n>>   git checkout -b devel\n>>   GIT_WORK_TREE=/path/to/devel git add -A\n>>   git commit\n>>\n>>   # and then check out the result in the working tree of\n>>   # your newly created repo\n>>   git checkout -f\n>\n> Better.\n>\n> -Brandon\n>\n"},{"id":"174637","messageId":"4E5E73D8.4040104@kdbg.org","threadId":"28268","inReplyTo":"201108311540.p7VFen5S015756@no.baka.org","subject":"Re: need to create new repository initially seeded with several branches","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2011-08-31T17:48:08Z","receivedAt":"2011-08-31T17:48:08Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 31.08.2011 17:40, schrieb in-git-vger@baka.org:\n> # Cause git to delete all files in the internal index\n> git read-tree --reset -i 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n> # Cause git to delete all files in the working directory\n> git clean -dfx\n> ...\n> The only \"magic\" is the read-tree/git-clean stuff.  The 4b82â€¦ value is\n> the SHA of an empty tree.  It could be replaced by...\n\n... a simple\n\n  git rm -rf .\n\n-- Hannes\n"}]}