Git Product home page Git Product logo

doppelganger's Introduction

Doppelganger

A tool to create and maintain mirrors of GitHub repositories. Once the repostiory is mirrored a webhook is set up, so next time you push to GitHub master mirror will be updated. You may also trigger an update manually by clicking "Synchronize repository".

Build Status Linters Check

Why Would I Need It?

Well, if you ask this question then most likely you won't. But next time some Chinese website decides to host their assets on GitHub you know you've been warned.

Installation

Create new personal access token with following permissions:

  • public_repo
  • write:repo_hook

Make sure you have git installed.

Download the latest release, extract it and then run:

DOPPELGANGER_GITHUB_TOKEN=<YOUR_PERSONAL_ACCESS_TOKEN> ./doppelganger 

This will run a server listening on 0.0.0.0:8081 and all mirrored repositories will go to ./mirror.

Run ./doppelganger --help to learn how to override these defaults.

Build From Source

# Download and compile
go get github.com/andrewslotin/doppelganger
# Current working dir should have templates/ and assets/ folders
cd $GOPATH/src/github.com/andrewslotin/doppelganger
# Run it
DOPPELGANGER_GITHUB_TOKEN=<YOUR_PERSONAL_ACCESS_TOKEN> $GOPATH/bin/doppelganger

Docker

docker pull andrewslotin/doppelganger
docker run -d --name doppelganger -e DOPPELGANGER_GITHUB_TOKEN=<YOUR_PERSONAL_ACCESS_TOKEN> -v /home/git:/var/mirrors -p 8081:8081 andrewslotin/doppelganger

See Docker Hub Page for details.

Usage

Mirrors can be used just like any other git remote. You can even push your changes there directly, but note that they will be discarded next time someone pushes to GitHub master.

Following exaples assume you have git user set up on your mirror server with HOME set to Doppelganger mirror directory.

Set up a new local copy of github.com/example/project from mirror:

git clone git@<doppelganger-host>:example/project

Use mirror as a second remote in already existing repository:

git add remote mirror git@<doppelganger-host>:example/project

# Make your local master using mirror as an upstream:
git branch --unset-upstream master
git branch --set-upstream master mirror/master
git reset master mirror/master

# Switch back to GitHub
git branch --unset-upstream master
git branch --set-upstream master origin/master

Mirroring Private Repositories

To mirror private repositories your personal access token should have repo permission.

Doppelganger uses git+ssh protocol to clone private repositories, which requires an SSH key to be present in the system. While attempting to clone a private repository Doppelganger will try to use an existing key stored in ~/.ssh. If there is no key it will attempt generate a new 2048-bit RSA key pair and offer to add the public key to the list of your GitHub SSH keys.

doppelganger's People

Contributors

andrewslotin avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

doppelganger's Issues

Clone repositories over SSH

Besides being insecure, Git protocol doesn't work for private repositories because it doesn't consider SSH keys. Doppelganger should use ssh_url instead of git_url.

Handle manual mirror deletions

When recreating repository mirror Doppelganger returns HTTP 500 with a message "Internal server error" after an attempt to set up GitHub push webhook fails. This happens because there is already a webhook with the same set of events and URL, in which case an error might be ignored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.