You already have a Git server

maurycyz.com

587 points by chmaynard a day ago


jonhohle - a day ago

I feel like something was lost along the way.

    git init —-bare
will give you a git repo without a working set (just the contents typically in the .git directory). This allows you to create things like `foo.git` instead of `foo/.git`.

“origin” is also just the default name for the cloned remote. It could be called anything, and you can have as many remotes as you’d like. You can even namespace where you push back to the same remotes by changing fetch and push paths. At one company it was common to push back to `$user/$feature` to avoid polluting the root namespace with personal branches. It was also common to have `backup/$user` for pushing having a backup of an entire local repo.

I often add a hostname namespace when I’m working from multiple hosts and then push between them directly to another instead of going back to a central server.

For a small static site repo that has documents and server config, I have a remote like:

    [remote “my-server”]
    url = ssh+git://…/deploy/path.git
    fetch = +refs/heads/*:refs/remotes/my-server
    push = +refs/heads/*:refs/remotes/my-laptop
So I can push from my computer directly to that server, but those branches won’t overwrite the server’s branches. It acts like a reverse `git pull`, which can be useful for firewalls and other situations where my laptop wouldn’t be routable.