The easiest way to Move (export, then import) a git repository

The easiest way to “move a git repository” is to clone the repository:

git clone http://github.com/foo.git

Edit the file foo/.git/config.  Remove the following:

[remote "origin"] url = https://github.com/foo.git fetch = +refs/heads/*:refs/remotes/origin/*

Change “back a directory”  ../

Import the repository:

git remote add origin https://github.com/my-new-repo.git git push -u origin master

This has the advantage of retaining the commit history from the previous repository.

Author | Miles Davenport

Career programmer, who designs, assembles, fixes, and supports customers, software and systems.