Setting up GIT server

This note provides how to setup private GIT repository server.

Server setup

Install git

yum install git

Create user
useradd gitacc
passwd gitacc

Create ssh directory
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
Create key to authenticate
ssh-keygen -C "youremail@mailprovider.com"
Create entries of public keys for allow users
cat .ssh/id_rsa.pub | ssh user@123.45.56.78 "cat >> ~/.ssh/authorized_keys"
Create project repository at server
cd /home/gitacc
mkdir "project"
cd "project"
git init --bare

Client configuration

Change to working directory
cd "project"
git init
git add .
git commit -m 'initial commit'
git remote set-url origin gitacc@128.199.136.183:mt/mt-project.git
git init
git remote add origin gitacc@128.199.136.183:mt/mt-project.git
Commit new file
git add test.txt
git commit -m 'created test.txt'
git push origin master
Clone project
git clone gitacc@128.199.136.183:mt/mt-project.git
Ref:

Comments