show code js

2021年7月20日 星期二

Create git server for self on centos

 :server


1.install

yum install git -y


2.add user

adduser git

passwd git


3.create directory for sample project

su git

cd ~

mkdir project.git

cd project.git

git init --bare


4.create ssh directory and file

cd ..

mkdir .ssh

cd .ssh

touch authorized_keys

chmod 700 ~/.ssh/

chmod 600 ~/.ssh/authorized_keys


5.create ssh key

su root

cd ~

ssh-keygen

scp ~/.ssh/id_rsa.pub git@gitserver:~/.ssh/authorized_keys

# or cat ~/.ssh/id_rsa.pub >> /home/git/.ssh/authorized_keys


:client


1.config

git config --global user.name "Your Name" 

git config --global user.email "Your_Mail@example.com"


2.type1:clone

:server create directory in /home/project.git

git clone git@gitserver:~/project.git

cd project 

touch test.txt

git add --all

git commit -a -m "First Version"

git push origin master


3.type2:create new project

:server create directory in /home/new_project.git

mkdir new_project

cd new_project

git init

git remote add origin git@gitserver:~/new_project.git

touch test.txt

git add --all

git commit -a -m "First Version"

git push origin master

沒有留言:

張貼留言