Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clone repository into GitHub

I have been using git locally for while a now and have a private repository with complete change history etc. I now want to share this on GitHub, so I need to clone from my local repo into a new GitHub repo. I cannot find any way to do this. How can I get all my history up onto GitHub?

like image 531
cdmh Avatar asked Apr 27 '12 07:04

cdmh


People also ask

Can I clone a local repository to Git?

git clone is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The original repository can be located on the local filesystem or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.


2 Answers

You don't need to "clone onto GitHub". You just have to create a repository on GitHub and push your changes there:

$ cd your_local_repo $ git remote add origin [email protected]:USERNAME/REPO_NAME.git $ git push origin master 
like image 196
Xion Avatar answered Sep 30 '22 07:09

Xion


You simply want to create a new repository on your account on GitHub. Assuming your account name is CraigH, and you call you new repository NewRepo (imaginative, I know), you'd simply (assuming you have GitHub keys set up on your system properly):

  1. Add a remote to your local repository
  2. Push out your current history to GitHub
    • git push --set-upstream origin master

And from that point, your history in the master branch are in GitHub's master branch.

like image 26
Romain Avatar answered Sep 30 '22 07:09

Romain