Setting up Git
Getting Git setup is quite a breeze if you know what is cooking.. If you don't.. Well I wish you luck..
Here is a step by step-guide on how to setup a SINGLE PROJECT repository Git environment that can be accessed by multiple users.
Step 1 : Installation
For your Windows Client : Download the latest version of Git
For your Ubuntu Linux Server (if you have some other distro of linux just adjust the way you get packages)
- apt-get git-core (You don't need gitosis)
- Check you have you ssh running. If not apt-get openssh-server (you don't need the client)
- (optional) Create a new user
Step 2 : Getting the pc's to "talk" to each other via SSH
What is SSH?
SSH is mechanism that allows two pc's to talk to each other without the use of passwords. The way it works is that your local machine will create a public key. We will pass this key to the server.
Now, everytime you request something from the server via SSH the server we see that you are included as a "special vip" and has the key, this will allow your pc direct access without needing a password.
So how do we get this all setup?
- If you haven't installed the Git client install it now
- Run Git Bash (you should have Git Gui and Git bash)
- Run the following Commands in Git Bash
- ssh-keygen -t dsa -C "name@something.com"
-t is used to inform ssh which type of encryption method we are using. Use "dsa"
-C allows you to link an identifier to the key. (makes it easier for the admin to read the authorized_keys file)Example :
ssh-keygen -t dsa -C user@homebox
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa): # Press 'enter' here
Enter passphrase (empty for no passphrase): # Press 'enter' here (we do this because we are trying to bypass password requests)
Enter same passphrase again: # Press 'enter' here
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
6f:c3:cb:50:e6:e9:90:f0:0f:68:d2:10:56:eb:1d:91 user@host - Next we want to access the linux server and make sure everything is 100%
- ssh user@ip-address Connect to the server (if it asks you if you want to save the fingerprint say "yes")
- cd ~/.ssh "~" takes you to the users home directory, .ssh is where all the important files are stored
- (optional) If .ssh doesn't exist, create it : mkdir .ssh
- cp authorized_keys backup_keys Make a backup of the current authorized keys
- exit Server is now ready
- Time to pass the key from your local machine to the server
- cd ~/.ssh
- scp id_dsa.pub user@ip-address:~/.ssh/yourname.pub password will be required
- ssh user@ip-address Again, password will be required
- cd ~./ssh
- cat yourname.pub >> authorized_keys We do this so that we don't remove the current keys from the file
- exit You should now be browsing your local machine
- ssh user@ip-address Just a test to make sure everything thing is working 100% (you should not be asked for a password)
- SSH has now been successfully completed between the two machines.
- ssh-keygen -t dsa -C "name@something.com"
Now that SSH is complete, we can finally setup Git
- Connect to the server again (ssh user@ip-address [no password should be required])
- You should be in the servers "Home" folder. (else just type cd ~)
- mkdir "projectname"
- cd "projectname"
- git init --bare --shared
--bare informs git that this will be purely for storing data (pushing). You will NEVER pull from this repo
--shared informs git that multiple users will be accessing this repo - Initialized empty shared Git repository in /user/somedirs/projectname/
- exit
- You should now be browsing your local machine again
- Browse to a desired folder you wish this project to be created
- git clone user@ipaddress:projectname
- Git will initialize the project for you.
- Happy coding
Need a bit of a crash course on Git.? Check out the following : http://www.spheredev.org/wiki/Git_for_the_lazy