How to set up a GIT repository locally

Simple setup to configure a local repository in your own machine for our own development.
The first step is to create a new user in your machine called git.
You can use any other name of your choice.

I have chosen the name git just for clarity in usage

$ sudo adduser git
Give password for new user git.

Login to git user or give ‘su git’ to log on to git user.
$ su git
$ cd /home/git

This step ensures that you are using the git (or the new userid you created)’s home directory.

Now create the repository and initialize it
$ mkdir ProjectName
$ cd ProjectName
$ git --bare init

Now you can logout from the git using below command.
$ exit

Steps need to follows another User of same machine:
Now go to the place where you want to work with your project.
$ mkdir MyProject
$ cd MyProject Clone the
$ git clone git@localhost:ProjectName
$ touch README
$ git add README
$ git commit -m "Adding README file" README
$ git push origin master git@localhost's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 250 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@localhost:ellisys 194963e..619d2af master -> master

That’s it, you can make any changes in your new project. Keep committing and pushing the changes. Thus you can track your project locally using git, without using any remote server

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
4 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.