Setting up a git server

In order to progress with my development projects, I needed to use a source control software, the best one for this is Git so I installed a Git server in one of my machines. I ran across some issues which I detail in the below steps list:

  1. Install Git in the server machine
    1. sudo apt-get install git
  2. Add a new user for git in the server.
    1. sudo useradd git
    2. passwd git
  3. Make sure to grant this user ssh access by editing /etc/ssh/sshd_config to add the line AllowUsers git
    1. sudo vi /etc/ssh/sshd_config
    2. sudo service sshd restart
  4. Test that you can ssh into the server with the user git from the client machine
    1. ssh
  5. create repository in server
    1. sudo su git
    2. mkdir $HOME/gittestrepository1.git
    3. cd $HOME/gittestrepository1.git
    4. git init –bare
  6. create repository in client and add some files which simulate the code you wish to store in the git repository
    1. mkdir testgitclientrepo1
    2. cd testgitclientrepo1
    3. echo this is code>codefile1.txt
    4. git init
    5. git add .
    6. git commit -m “comitting code” -a
  7. Push the changes to the server
    1. git remote add origin ssh://
    2.  git push origin master
  8. Anybody who wishes to download the code can do so with the following command
    1. git clone
  9. After they modify the code, if they want to push it into git, they must identify themselves at least the first time.
    1. git config –global “”
    2. git config –global “Roge Retropie”
    3. git commit -m “modification from retropie” -a
    4. git push origin master
  10. When working in a distributed team, when you want to update your local codebase in the morning with the changes done by your colleagues, run
    1. git pull origin master
  11. If you have done changes to your local code which you wish to discard and overwrite your local copy with the latest server copy
    1. git checkout — .
    2. git pull origin master




One thought on “Setting up a git server

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s