GIT Setup

This page was created as a reference to creating repositories.

I recommend that everyone setup some type of concurrent versioning system for their projects. I have only had experience with CVS and GIT, but I find that GIT better serves me with its ease of setup and use. I do most of my development on Linux, so I prefer working with the command line. There are many UIs, such as GITHUB, eclipse plugins, and others that are Windows friendly as well.

I am making the assumption that the SSH server is set up on the host with the required ports open and the client server has SSH and the .ssh/config file already setup. If you not, you can check my SSH guide on how to set it up.

Initial Setup

  • Install GIT onto the host and client server.
    • On Ubuntu(Debian): sudo apt-get install git
    • On Redhat(Fedora): sudo yum install git
  • Create Empty Repo on the host server
    • I typically create mine in the /var directory: /var/git/project.git
      • sudo mkdir /var/git; sudo mkdir /var/git/project.git
    • Now we will create an empty repository for where we will push our project.
      • In the /var/git/project.git directory enter the following command.
        • sudo git –bare init
        • You now have an empty repository ready to store your project.
    • Next create a user and group for the user/group who will handle the creations, commits and pushes. Then apply the permissions. EX:
      • sudo chown git.git -R /var/git
      • sudo chmod 755 -R /var/git
  • On the client server initialize your existing project or the directory where you will be creating your project.
    • In the root directory of the project you will be pushing. Enter the following commands:
      • git init
      • git remote add origin ssh://host//var/git/project.git
        • Please take note that ‘host’ will be the server config you created in the .ssh/config file. Otherwise if you are using port 22 for ssh then you can use the following command. Also not that can also be an IP address if preferred or if using a server on a local network.
        • . git remote add origin ssh://
      • Next we will add the project contents.
        • git add .
      • Next commit. Your message can be anything you prefer.
        • git commit -m ‘Initial Commit’
      • Push the contents to the repository
        • git push origin master
      • If you would, you can set the tracking of the master branch. To do so enter the following command.
        • git branch –set-upstream-to=origin/master master
        • If not, when you pull, instead of (git pull), use (git pull origin master)

Client Setup (If the host server and repository are already configured and contains a project to be pulled)

  • Assuming that the SSH configurations are setup, simply clone the repository to the directory of your liking with the following command.
    • git clone ssh://host//var/git/project.git
  • Or, if you aren’t using a .ssh/config file then use:
    • git clone ssh://