How to set up a Git repository in minutes on Linux

In the event you want a fast code repository, you’ve gotten every thing you want with git and SSH. Jack Wallen reveals you the way it’s completed.

Developer young woman

Picture: Getty Pictures/iStockphoto

Typically you simply have to deploy a fast Git repository so you may collaborate on a challenge, again up your code or home your information on a distant machine. While you really feel like doing that, you do not wish to need to spend an hour or so deploying a server and setting it up … particularly when you have already got every thing you want at your fingertips.

I will present you how one can rapidly deploy a Git repository utilizing simply git and ssh. You need to have the ability to spin this up in lower than 5 minutes (two, when you sort quick).

Let’s get busy.

What you may want

The one factor you want is a Linux machine (both a desktop or a server) to host the repository and a person with sudo privileges. That is it.

SEE: Hiring Equipment: JavaScript Developer (TechRepublic Premium)

Tips on how to set up git

You most likely have already got git put in in your native machine. On the off likelihood you do not have it put in on the distant machine, log into it and set up with:

  • For Debian-based methods – sudo apt set up git -y
  • For Pink Hat-based methods – sudo dnf set up git -y

Git ought to now be put in.

Keep logged into the distant machine.

Tips on how to create a git person and duplicate your SSH keys

On the distant machine create a git person with:

sudo adduser git

Give the brand new person a password and reply the remaining questions.

Change to the git person with:

su git

Develop into the git customers’ HOME listing with:


Create the .ssh listing and provides it the right permissions:

mkdir .ssh
chmod 700 .ssh

Create the authorized_keys file and provides it the right permissions with:

contact .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

Now, in your native machine view the file of the person who will likely be engaged on the git repository with the command:

cat /residence/USER/.ssh/

The place USER is the person who’ll be working with git. Copy that key to your clipboard. 

Open the authorized_keys file on the distant machine with:

nano /residence/git/.ssh/authorized_keys

Paste the important thing after which save and shut the file.

Tips on how to create the repository

Again in your distant machine create a repository listing (nonetheless because the person git) within the git customers’ residence with:

mkdir /residence/git/git_repo

Develop into that listing with:

cd /residence/git/git_repo

Create a brand new challenge listing (we’ll identify it PROJECTX) with:


Develop into that new listing with:


Initialize the brand new (naked) git repository:

git --init naked

Tips on how to clone the brand new repository

Again at your native machine, difficulty the command:

git clone [email protected]:/residence/git/git_repo/PROJECTX

The place REMOTE is the IP deal with of the distant machine housing the git challenge.

Try to be prompted to your SSH key authentication password. Upon profitable authentication, the challenge will clone and also you’re able to go. If you wish to check this repository, create a README in PROJECTX (on the native machine) with:

contact README

Now, we’ll push the adjustments to the repository by including the information, making a commit, and pushing with:

git add --all
git commit -m "Added README file"
git push origin grasp

There ya go. You have created a repository on a distant machine, initialized a brand new challenge, cloned the challenge to an area machine, made adjustments, and pushed your adjustments to the repository. This could take you lower than 5 minutes.


Additionally see

Recent Articles


Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox