All of lore.kernel.org
 help / color / mirror / Atom feed
* need to create new repository initially seeded with several branches
@ 2011-08-31 15:25 ryan
  2011-08-31 15:40 ` in-git-vger
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: ryan @ 2011-08-31 15:25 UTC (permalink / raw)
  To: git

Noobie here...Don't ask why, but I have essentially 3 branches in separate
code bases on my file system that aren't in a repository right now.  

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.

Is there a way to do this?  Could someone give me a step by step?  I am
having a hard enough time just getting use to git and I am lost trying to
figure this out.

thanks so much

--
View this message in context: http://git.661346.n2.nabble.com/need-to-create-new-repository-initially-seeded-with-several-branches-tp6746957p6746957.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: need to create new repository initially seeded with several branches
  2011-08-31 15:25 need to create new repository initially seeded with several branches ryan
@ 2011-08-31 15:40 ` in-git-vger
  2011-08-31 16:10   ` Ryan Wexler
  2011-08-31 17:48   ` Johannes Sixt
  2011-08-31 16:14 ` Brandon Casey
       [not found] ` <uvMkLVapQYcSvOHVhcHX8CqGzEDajPEPvBbkL_DctzZvxm7aI-PjCQ@cipher.nrlssc.navy.mil>
  2 siblings, 2 replies; 11+ messages in thread
From: in-git-vger @ 2011-08-31 15:40 UTC (permalink / raw)
  To: ryan; +Cc: git


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: need to create new repository initially seeded with several branches
  2011-08-31 15:40 ` in-git-vger
@ 2011-08-31 16:10   ` Ryan Wexler
  2011-08-31 16:21     ` in-git-vger
  2011-08-31 17:48   ` Johannes Sixt
  1 sibling, 1 reply; 11+ messages in thread
From: Ryan Wexler @ 2011-08-31 16:10 UTC (permalink / raw)
  To: in-git-vger; +Cc: git

On Wed, Aug 31, 2011 at 8:40 AM,  <in-git-vger@baka.org> wrote:
>
> 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
>

Seth-
Thanks for the extensive reply.  I am excited that this is even possible.

I have to say that I am lost by the "magic" you describe.  I don't
understand what you mean by the 4b82... value should be replaced by
the find | xargs remove all command.   That command looks like it just
deletes all the "." file names?  But when you say replace I thought
you would mean I need to generate a new value to replace that magic
number??  Confused...

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: need to create new repository initially seeded with several branches
  2011-08-31 15:25 need to create new repository initially seeded with several branches ryan
  2011-08-31 15:40 ` in-git-vger
@ 2011-08-31 16:14 ` Brandon Casey
  2011-08-31 16:54   ` Jeff King
       [not found] ` <uvMkLVapQYcSvOHVhcHX8CqGzEDajPEPvBbkL_DctzZvxm7aI-PjCQ@cipher.nrlssc.navy.mil>
  2 siblings, 1 reply; 11+ messages in thread
From: Brandon Casey @ 2011-08-31 16:14 UTC (permalink / raw)
  To: ryan; +Cc: git

On 08/31/2011 10:25 AM, ryan@iridiumsuite.com wrote:
> Noobie here...Don't ask why, but I have essentially 3 branches in separate
> code bases on my file system that aren't in a repository right now.  
> 
> 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.
> 
> Is there a way to do this?  Could someone give me a step by step?  I am
> having a hard enough time just getting use to git and I am lost trying to
> figure this out.

So, you want your repository and dag to look like this:

     *------*------*
     |      |      |
  master  devel  topic

but it may help you visualize it to write it like this:

  master *
          \
     devel *
            \
       topic *

Just be aware that the above two are the same.  If you don't understand
that now, then let this plant the seed in your brain of the concept that
branches are merely "pointers" to a state of your repository.  Don't
worry, you don't have to understand that now in order to get started
and accomplish what you are trying to do...

First, create your git repository based on the code in the directory
holding what you would like to become the master branch.

Either

   cd $path_to_master_code

or

   mkdir $my_new_project_directory &&
   cd $my_new_project_directory &&
   cp -a $path_to_master_code/* .

then

   git init &&
   git add . &&
   git commit -m 'Initial import into git'

Voila, you have your master branch.  Now just create your devel
branch and copy your devel code into it and commit.

   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.

Please make sure you read the man pages for the above commands and
understand what is going on before you do it, and double-check my
commands.

-Brandon

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: need to create new repository initially seeded with several branches
  2011-08-31 16:10   ` Ryan Wexler
@ 2011-08-31 16:21     ` in-git-vger
  0 siblings, 0 replies; 11+ messages in thread
From: in-git-vger @ 2011-08-31 16:21 UTC (permalink / raw)
  To: Ryan Wexler; +Cc: git


In message <CAKjsY4nsPNO_kvxeime8qcNrRFykgG2TOYxJ0HKbj2zR5Rwv+Q@mail.gmail.com>, Ryan Wexler writes:

    > # 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

    > 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

    I have to say that I am lost by the "magic" you describe.  I don't
    understand what you mean by the 4b82... value should be replaced by
    the find | xargs remove all command.   That command looks like it just
    deletes all the "." file names?  But when you say replace I thought
    you would mean I need to generate a new value to replace that magic
    number??  Confused...

I was just trying to explain what the git-read-tree and git-clean
commands are doing.  The long string starting with 4b825d is a special
SHA that git knows represents an empty tree.  I was saying that you
*could* (not should) replace the two commands (git-read-tree and
git-clean) with the "find | xargs rm" command I quoted.  The two sets
of commands are equivalent.

Also, if you look at the find command, I am finding everything
*except* the .git . and .. directories

					-Seth Robertson

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: need to create new repository initially seeded with several branches
       [not found]   ` <201108311624.p7VGOWWq018472@no.baka.org>
@ 2011-08-31 16:45     ` Brandon Casey
  2011-08-31 16:54       ` Brandon Casey
  0 siblings, 1 reply; 11+ messages in thread
From: Brandon Casey @ 2011-08-31 16:45 UTC (permalink / raw)
  To: in-git-vger; +Cc: ryan, Git Mailing List

On 08/31/2011 11:24 AM, in-git-vger@baka.org wrote:
> 
> In message <sDZ5pnWzh3ZbFYS6GK-NcPdn09kF53MJ2eRkBnzInzdL8-cvCiF5beUw2k9Pz6BTq-Y3i_XwpYfgTOvXNlP1vPjLSHJ6FIzxL0jN1W0d0M8@cipher.nrlssc.navy.mil>, Brandon Casey writes:
> 
>        rm -rf * &&               # remove the files in the working dir
> 
> I just note (for your information only) that this doesn't get rid of
> any . files which might exist.  That is the advantage of the
> git-read-tree;git-clean or the `find | xargs rm` alternatives I
> mentioned in my post.  99% of the time it doesn't matter of course,
> since it would only fail on . files which were deleted in the data
> stream you were replacing.

I was just crafting a reply to your message to say the same thing.

Note also that the dot files would not have been copied into the
working directory in the first place, using a command like this:

   cp -a /some/path/* .

So, Ryan, if your project contains dot files that you would want
to track, take care that they are actually copied and deleted
with the other files while you are creating your repository.

-Brandon

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: need to create new repository initially seeded with several branches
  2011-08-31 16:14 ` Brandon Casey
@ 2011-08-31 16:54   ` Jeff King
  2011-08-31 17:01     ` Brandon Casey
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff King @ 2011-08-31 16:54 UTC (permalink / raw)
  To: Brandon Casey; +Cc: ryan, git

On Wed, Aug 31, 2011 at 11:14:48AM -0500, Brandon Casey wrote:

>    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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: need to create new repository initially seeded with several branches
  2011-08-31 16:45     ` Brandon Casey
@ 2011-08-31 16:54       ` Brandon Casey
  0 siblings, 0 replies; 11+ messages in thread
From: Brandon Casey @ 2011-08-31 16:54 UTC (permalink / raw)
  To: Git Mailing List


@Seth Robertson

Your email address seems to be broken.  My message to you bounced:

   ----- The following addresses had permanent fatal errors -----
<in-git-vger@baka.org>
    (reason: 550 5.1.1 <in-git-vger@baka.org>... User unknown)

   ----- Transcript of session follows -----
... while talking to tsutomu.baka.org.:
>>> >>> DATA
<<< 550 5.1.1 <in-git-vger@baka.org>... User unknown
550 5.1.1 <in-git-vger@baka.org>... User unknown
<<< 503 5.0.0 Need RCPT (recipient)

   ----- Original message follows -----
<snip>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: need to create new repository initially seeded with several branches
  2011-08-31 16:54   ` Jeff King
@ 2011-08-31 17:01     ` Brandon Casey
  2011-08-31 17:09       ` Ryan Wexler
  0 siblings, 1 reply; 11+ messages in thread
From: Brandon Casey @ 2011-08-31 17:01 UTC (permalink / raw)
  To: Jeff King; +Cc: ryan, git

On 08/31/2011 11:54 AM, Jeff King wrote:
> On Wed, Aug 31, 2011 at 11:14:48AM -0500, Brandon Casey wrote:
> 
>>    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

Better.

-Brandon

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: need to create new repository initially seeded with several branches
  2011-08-31 17:01     ` Brandon Casey
@ 2011-08-31 17:09       ` Ryan Wexler
  0 siblings, 0 replies; 11+ messages in thread
From: Ryan Wexler @ 2011-08-31 17:09 UTC (permalink / raw)
  To: Brandon Casey; +Cc: Jeff King, git

Ok thanks for all the replies guys.  I thought I was SOL.  I will
start playing with it here and let you know how it goes.

On Wed, Aug 31, 2011 at 10:01 AM, Brandon Casey
<brandon.casey.ctr@nrlssc.navy.mil> wrote:
> On 08/31/2011 11:54 AM, Jeff King wrote:
>> On Wed, Aug 31, 2011 at 11:14:48AM -0500, Brandon Casey wrote:
>>
>>>    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
>
> Better.
>
> -Brandon
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: need to create new repository initially seeded with several branches
  2011-08-31 15:40 ` in-git-vger
  2011-08-31 16:10   ` Ryan Wexler
@ 2011-08-31 17:48   ` Johannes Sixt
  1 sibling, 0 replies; 11+ messages in thread
From: Johannes Sixt @ 2011-08-31 17:48 UTC (permalink / raw)
  To: in-git-vger; +Cc: ryan, git

Am 31.08.2011 17:40, schrieb in-git-vger@baka.org:
> # 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
> ...
> 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 simple

  git rm -rf .

-- Hannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-08-31 17:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-31 15:25 need to create new repository initially seeded with several branches ryan
2011-08-31 15:40 ` in-git-vger
2011-08-31 16:10   ` Ryan Wexler
2011-08-31 16:21     ` in-git-vger
2011-08-31 17:48   ` Johannes Sixt
2011-08-31 16:14 ` Brandon Casey
2011-08-31 16:54   ` Jeff King
2011-08-31 17:01     ` Brandon Casey
2011-08-31 17:09       ` Ryan Wexler
     [not found] ` <uvMkLVapQYcSvOHVhcHX8CqGzEDajPEPvBbkL_DctzZvxm7aI-PjCQ@cipher.nrlssc.navy.mil>
     [not found]   ` <201108311624.p7VGOWWq018472@no.baka.org>
2011-08-31 16:45     ` Brandon Casey
2011-08-31 16:54       ` Brandon Casey

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.