Skip to content

Instantly share code, notes, and snippets.

@slattery
Last active August 29, 2015 14:11
Show Gist options
  • Save slattery/08a14dc4aa367d21eb6d to your computer and use it in GitHub Desktop.
Save slattery/08a14dc4aa367d21eb6d to your computer and use it in GitHub Desktop.
populate github fresh repo with old existing stuff
Create a new repository on GitHub. You'll import your external Git repository to this new repository.
On the command line, make a "bare" clone of the repository using the external clone URL. This creates a full copy of the data, but without a working directory for editing files, and ensures a clean, fresh export of all the old data.
git clone --bare https://githost.org/extuser/repo.git
# Makes a bare clone of the external repository in a local directory
Push the locally cloned repository to GitHub using the "mirror" option, which ensures that all references, such as branches and tags, are copied to the imported repository.
cd *repo.git*
git push --mirror https://github.com/ghuser/repo.git
# Pushes the mirror to the new GitHub repository
Remove the temporary local repository.
cd ..
rm -rf repo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment