I’ve been learning a lot about Git over the last few months, & I wanted to start sharing a bit of what I’ve learned. We’ve been using GitHub at work, & it’s great, really great. But I wanted to be able to centrally host a git repo on our servers that acts as dedicated storage. I’m not going to use the git repo on the server as an actual development environment, just as a place to store the files that everyone else will use. In other words, I wanted to duplicate the GitHub experience on our servers. Here’s how.
Note that this setup works for us. It may not work for you. Notably, we’re all signing in as the same user. We all sign our commits, however. For a larger team, that wouldn’t fly. Test!
Table of Contents
Set up the git repo on the server (crashaw.foobar.com)
Say you have a server named crashaw.foobar.com. Connect to that server & create the directory for the repo:
--bare tells git that this a storage directory for a repo, not an actual development environment.
CLI: Set up the git repo on your local machine A
You now have a bare repo on the server. Basically, you now move to your local computer, the real development environment (well, one of them, anyway), put the files you want to work on into your local repo, & push them to the server where they can be shared collaboratively.
CLI: Set up the git repo on a different local machine B
Now someone else copies the repo to their computer so they can work on it too.
CLI: git pull & git push
Now you can use
git pull &
git push as normal on either machine. Here’s an example.
On machine A:
On machine B:
GUI: Set up the git repo on your local machine A using Tower
I like the command line, but my business partner prefers to use GUI tools (although he’s quite proficient on the CLI). We both use Tower on our Macs, a very nice GUI for git (& other source code management tools). Here’s how to configure Tower to work with the self-hosted repo I detailed above.
Go to Manage Repositories.
Press Clone Remote Repository.
Enter the following information:
- Repository URL:
- Bookmark Title: [Autofills with server-repo; you can change if you’d like]
- Authentication: Private Key
- Private Key: [Select appropriate key]
- Key Password: [Leave empty]
- Clone To:
You can now proceed as usual, as you’re used to with GitHub, but now the repo is on our server.