Skip to content

Instantly share code, notes, and snippets.

@neolaw84
Last active May 25, 2019 05:45
Show Gist options
  • Save neolaw84/f5bc241d3bda873a5236bd030cc66f98 to your computer and use it in GitHub Desktop.
Save neolaw84/f5bc241d3bda873a5236bd030cc66f98 to your computer and use it in GitHub Desktop.
Mirroring git repository in github

Mirroring a Git Repository in Github

Situation/Problem

A git repository is present in local (or somewhere on the net) but it is not in github.

We want to replicate the commit history (and all branches) in github.

Action/Solution

Refer to https://help.github.com/en/articles/importing-a-git-repository-using-the-command-line

  1. Create a bare clone
git clone --bare path/to/local/git/repository.git
  1. Create a github repository (via GUI)

  2. Push (mirror) the bare clone to github

cd repository.git
# assuming authetication public key etc are set up in github
git push --mirror /path/to/github/url

Results

All history (commits and branches) are cloned in github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment