1. Server Setup

  • First, you need to update your system and install necessary packages to your system. To update the system and install the SSH server on the server machine, run the following command:

sudo apt-get update
sudo apt-get install open ssh-server

  • Second, install Git on server machines. You can install Git from the packages already available via the repos or your distros, or you can do it manually. In this article we will use the simpler method:

sudo apt-get install git-core

  • Then add a user for Git.

sudo useradd git
passwd git

  • In order to ease access to the server let’s set-up a password-less ssh login. First create ssh keys on your local machine:

ssh-keygen -t rsa

  • Now ssh into the server and create a project directory for Git. You can use the desired path for the repo

mkdir -p /opt/git/<project-name>.git
cd /opt/git/<project-name>.git
sudo git init –bare –shared

  • Check Your User Groups to follow command

    groupsuser git

  • Go to your repo path as follow

cd /path/to/repo.git
chgrp -R groupname .
chmod -R g+rwX .
find . -type d -exec chmod g+s ‘{}’ +

Server side set up completed.

 

2. Now need to setup on Client System


  • First, you need to update your system and install necessary packages to your system. To update the system and install the SSH server on the client machine, run the following command:

sudo apt-get install openssh-client

  • We now need to create a Git repo on the local machine.

mkdir -p /dirname/project

  • And change to this directory:

cd /dirname/project

  • Now create the files that you need for the project in this directory. Stay in this directory and initiate git:

    git init

    Initialized empty Git repository in your directory

  • Now, Clone repository to your local directory

git clone username@hostname:<git path>

  • Now add files to the repo, for example test.html Add to Server

git add *

  • Now they can edit files, write commit change messages and then push them to the server:

git commit -m ‘File added’

  • And then push changes:

    git push origin master

I hope this document helpful for yours.

You may also like

Leave a Reply