Re: need to create new repository initially seeded with several branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/31/2011 10:25 AM, ryan@xxxxxxxxxxxxxxxx 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]