Setup Private Git On Cent OS 7

I just ruined my cozy returning, from the hospital. Because I couldn't hold myself stop getting fury when I was having a call with my wife. She responsed so impatient when I asked is there any thing to eat for my Mom. My mom went to the hospital to take me back after 7 days diagnosis & recuperation. What I felt about the tone from my wife was she has been building up a bad image to my mom, and it's mutual, my mom have tons of trivias to complain about. How big the rift is! What I like to do is to hide myself somewhere, or even more, definitely disappear for a while. These misunderstandings kept growing when I was not with them. Now it's time to face them.

My wife started a cold war with me, no unnecessary conversation, no simle, no eye communication. And the agreement went to termless isolation between she and my mom. So frustrated.

All the white

So yesterday I tried to setup my private git on my VPS, it’s my way to get myself relaxed.

Step 1 Create the SSH Key Pair

1
ssh-keygen -C "youremail@mailprovider.com"

Step 2 Setup a git user

1
adduser git

set password to git
1
passwd git

Then
1
visudo

find “root ALL=(ALL) ALL” grant the privileges to new user with adding this:
1
git ALL=(ALL) ALL

Step 3 install git on Cent OS 7

  • Update all your yum.
    1
    yum -y update
  • Install Git
    1
    yum -y install git

Step 4 switch to user git

Very important, the first time I failed here because I did all the steps next with user ‘root’.
1
su git

Step 5 config git

1
2
git config --global user.name "Tiger Wang"
git config --global user.email "youremail@mailprovider.com"

Step 6 Add id_rsa to your VPS SSH

Transport your id_rsa.pub file to your remote VPS. Then create key file with:
1
2
mkdir ~/.ssh && touch ~/.ssh/authorized_keys
cat .ssh/id_rsa.pub | ssh git@yourhost "cat - >> ~/.ssh/authorized_keys"

Now you can see the key there if you use cat on the authorized key file:
1
cat ~/.ssh/authorized_keys

Step 7 Create a Git Repository

Create a new directory as the source repository. Get into it then

1
git init --bare my-project.git

After this, you’ll see some output like this

1
Initialized empty Git repository in /home/git/my-project.git/

Note it down, we’ll use it later.

Step 8 Clone this project to your local Mac

Open terminal, enter into any directory you want to use as repository. Then(Make sure you have git installed on your Mac):
1
2
git init && git remote add origin git@yourhost:/home/git/my-project.git
git clone git@yourhost:/home/git/my-project.git

Step 9 Run your own repository locally.

Now you have a local clone of the remote project.
Add something in it.Then try to commit it to the remote server.

1
2
touch README
vi README

Edit the file with vi, change any thing you want.

1
2
git add .
git commit -m "Initial" -a

Remember this commit is commiting file to local repository. if you want to push it to the remote VPS, you need to

1
git push origin master