Developers often need to set a local git repository or local git server where you can save versions of your code.

Here is a way to go.

Step-1: create git repository on server

We are going to setup git server on local machine. So first need to set the repository.

$ cd /var
$ mkdir git
$ cd git
$ mkdir <project-name>
$ cd <project-name>
$ mkdir .git
$ cd .git
$ git --bare init

Step-2: Add git server url to your project

Now get back to project directory

$ cd /home/username/<project-name> 
$ git init
$ git add --all
$ git commit -m 'first commit'
$ git remote add origin /var/git/<project-name>/.git

Step-3: push your project to git

$ git push -u origin --all