Import an Existing git Repository to GitHub
  Aug 27, 2011

GitHub does not care if you created the repo there or not... after all, it's still plain 'ol git in the backend. That being said, you can easily change the push origin of an existing repository and you will have all of the history and information you are used to.

  1. create a repository on the GitHub website
  2. check out the existing repository that you want to import into GitHub
  3. change the push location
  4. push to the new location

First, go to GitHub and create a blank repository. Then, tell git what you want to do.

  1. $ git clone <some repo>
  2. $ cd <some repo>
  3. $ git remote -v
  4. origin    olduser@oldhost.com:OldRepoName.git (fetch)
  5. origin    olduser@oldhost.com:OldRepoName.git (push)
  6. $ git remote rm origin
  7. $ git remote add origin git@github.com:YourUserName/NewRepoName.git
  8. $ git push -u origin master

Now, you should be able to use git like you normally do... only now you're pushing to GitHub!




Post a New Comment

Name

Message

Security
Code

        (case insensitive & space between words)


Posted Comments
Hugues Landry  Dec 27, 2011
Thanks for this tips, helped a lot!