GithubHelp home page GithubHelp logo

gitmirror's Introduction

What's This?

I've got a few git repos places I automatically clone git repos and wanted to make sure these things stay up-to-date. Some repos are on github, some are on other machines around the internet. They all look the same here.

How Do I Use This?

Setting Up a Repo Path

First, you'll need stuff for it to do. Let's say we wanted to set up a repository mirror location in /tmp/gitmirrors and our first mirror will be of my awesome gitmirror project.

First, install the software:

go get github.com/dustin/gitmirror

Now, create a location for your mirrors and (as an example), check out the gitmirror source into it:

mkdir /tmp/gitmirrors
cd /tmp/gitmirrors
git clone git://github.com/dustin/gitmirror

(note, don't actually use /tmp/ as your permanent mirror path)

Note for Github Usage

If you're planning to use gitmirror with github, it will automatically create the mirrors for you on first contact, so you just need to make sure the default directory is there.

Getting gitmirror Running

gitmirror is a standalone web server written in go. It's been tested on several platforms, but I mostly use it on Linux and MacOS X.

Once you have your gitmirror binary built (Which happens automatically with the go get command above), you run it like this:

/path/to/gitmirror -git=/path/to/git -dir=/tmp/gitmirrors

Trying it Out

Now, you can use curl to play around and do repo syncs:

curl http://localhost:8124/gitmirror.git

The above does a background sync and responds immediately with an http 202 (you can add -D - if you don't believe me). If you want a foreground sync, you can do the following:

curl 'http://localhost:8124/gitmirror.git?bg=false'

Now you'll either get an http 200 or 500 depending on whether it was successful along with the contents of stdout and stderr so you can see what happened.

Productionalizing

I've got a sample launchd .plist file in the support directory because I happen to be running it on a mac.

See my blog post on running processes for more detail on actually running stuff. I'm sure you can figure out the rest.

The machine I'm running this on doesn't have a web server, so I'm actually doing a path translating proxy through nginx to get it here. My nginx config looks not entirely unlike this:

upstream gitmirror {
    server 10.10.3.21:8124;
}
server {
    [...];
    location /gm/ { proxy_pass http://gitmirror/; }
}

Now I've got a URL available on the internet I can use to set up github post-receive-hooks to update as well as git post-commit hooks for the more private/weird stuff.

Hooks

gitmirror will run post-fetch hooks for you if you have them available. One or both of the following will be executed (in this order):

  • $gitmirrordir/current_repo.git/hooks/post-fetch
  • $gitmirrordir/bin/post-fetch

The first is the repository specific hook, allowing you to do stuff like CI integration or doc builds or something.

The second is a single global hook that will run for every repo allowing you to have a common behavior across all updates (e.g. you might want to touch 'git-daemon-export-ok' or post something to twitter or chain a different hook or something.

Batches of Hooks

If you have a ton of hooks to set up, check out the setuphooks command. It works great for hundreds of repos with simple patterns to express how you want them to map to your mirror.

gitmirror's People

Contributors

dustin avatar trondn avatar

Watchers

 avatar  avatar  avatar

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.