Thursday, January 28, 2010

How to clone a Github Repository

I want to create a backup repository that includes all git history before I restart a new project. I need to restruct our project but we want to create a repository for old git and work on new code at the same respoitory.

That is,

a. Local PC: source code version controlled with git@github.com:myaccount/current_project.git

b. github server: create a new repo named https://github.com/myaccount/backup_project

c. want to push Local PC's source code to the new repo named https://github.com/myaccount/backup_project

d. Keep the old git: git@github.com:myaccount/current_project.git


Assuming you have a githu account.
(1) Create a new repositoty for backup
Go to http://github.com/repositories/new

(2) Fill out the textbox on the page and URL for the new repository
For example: URL should be
https://github.com/myaccount/backup_project

(3) Make sure if you have a local repository for the current project. Thus, create a loal repository in case:
git clone git@github.com:myaccount/current_project.git current_project_01282010

(4)Then
cd current_project_01282010
git remote add origin git@github.com:myaccount/backup_project.git

(5) If it has a following error:
fatal: remote origin already exists.

cd config
vi config

Then, rename the origin to "git@github.com:myaccount/backup_project.git" from "git@github.com:myaccount/current_project.git"

(6) at gihub.com/myaccount/backup_project.git, don't forget to add your local account as Repository Collaborators.

(7) push your local repository to git@github.com:myaccount/backup_project.git
git push origin master

Followers

Profile