I was originally introduced toGit will working with Puppet and Chef configurations. After having leveraged other CMS in the past such as CVS and SVN, I simply found Git easier and more enjoyable to use.
While I don’t code per se, I treat all my configurations as code and revision them as such. It ties in nice with working across multiple systems while enabling me to take my work with me even when it is not truly with me. While I still do have and and use a GitHub account, I often find myself in situations in which I don’t want to publish my content to GitHub. For this, I run my own Git Server. This HowTo is only to show you how to setup a Git Server. There are plenty of great tutorials already out there that help explain the details of Git.
These are just a few links to some great tutorials on Git.
The real secret sauce to Git in my opinion, is its use of SSH Keys for authentication. While you can use a password, it does not work well with multi-user setups. Key’s are easy to manage and revoke, allowing for a central authority of remote access.
1. Install Git
If you are on MAC OS X and have xCode installed you already have the core functionality required to follow along.
2. Create a GIT User
If you are familiar with SSH Keys, this will seem rather simple however if you have not used SSH Keys for password less authentication, I recommend you read this for further understanding. The actual creating of a “Git” user is completly optionial as you can use your existing user. The purpose for creating a standalone user is that you can share this with multiple individuals.
3. Create SSH Keys for the Git User
As the newly created git user, run the following commands.
1 2 3
Accept all the defaults and hit enter for the passphrase. We want the passphrase to be blank. These commands setup your SSH directory for Git as well as installs a secure RSA key.
4. Create Client SSH Keys
On the client
If you do not already have an .ssh directory or any SSH keys, we will go ahead and set them up. If you do have keys, skip this step and go down to Step 5.
1 2 3
You then have to get copy your id_rsa.pub contents to the user Git on the server to a file called ~/.ssh/authorized_keys. There are many ways to get this key on the server however for this tutorial, we will just use the good old copy/paste method.
5. Copy CLient SSH Keys to Server
On the client
Copy to the clipboard
1 2 3
Paste from clipboard and save.
From the client as the user who you want to grant access to.
6. Create Empty Git Repository
On the server (as the git user) run the following command.
7. Clone Repository to Client
1 2 3
This created a directory called testing on your local client.
8. Setup Git Global Variables
Run the following commands.
9. Commit Changes
1 2 3 4 5
If all is successful, you should have something like this.
1 2 3 4 5 6 7