第一:关于SSH的设置
1、 在客户端
[root@ ~]# ssh-keygen //生成公匙和密匙
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
af:7a:4c:de:69:7d:5d:4c:74:41:2f:4b:9a:9f:69:08 root@
[root@ ~]# scp .ssh/id_rsa.pub 192.168.1.193:/root //把自己的公匙上传到服务器
The authenticity of host '192.168.1.193 (192.168.1.193)' can't be established.
RSA key fingerprint is 0a:54:06:f8:28:41:bd:cd:bd:e6:fa:ae:de:56:24:78.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.193' (RSA) to the list of known hosts.
root@192.168.1.193's password:
id_rsa.pub 100% 396 0.4KB/s 00:00
2、在服务器端的设置
[root@ ~]# ssh-keygen //下边不输入任何一直点击确认
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
07:8f:af:6b:15:9c:7a:9b:7c:a8:7e:41:dd:bd:1f:56 root@
[root@ ~]# cat id_rsa.pub >> .ssh/authorized_keys //导入客户端的公匙
第二:关于git安装和配置
1、 在服务器端和客户端的公共配置
[root@ ~]# ls git-1.7.7.4.tar.gz
git-1.7.7.4.tar.gz
[root@ ~]# tar zxvf git-1.7.7.4.tar.gz
[root@ ~]# cd git-1.7.7.4
[root@ git-1.7.7.4]# ./configure
[root@ git-1.7.7.4]# make && make install
[root@ git-1.7.7.4]# cp contrib/completion/git-completion.bash ~/.git-completion.bash
[root@ git-1.7.7.4]# vi ~/.bashrc //加入下句话
source ~/.git-completion.bash
[root@ git-1.7.7.4]# source ~/.bashrc
2、 在服务器端仅有的操作
[root@ ~]# mkdir -p /opt/git/mygit
[root@ mygit]# git --bare init //创建“仓库“
Initialized empty Git repository in /opt/git/mygit/
3、 在客户端的操作
[root@ ~]# mkdir /git
[root@ ~]# cd /git/
[root@ git]# git init
Initialized empty Git repository in /git/.git/
[root@ git]# vim README
Hello ethnicitybeta!
[root@ git]# git add .
[root@ git]# git commit -m "1st commmit"
[master (root-commit) e28450f] 1st commmit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 README
[root@ git]# git remote add origin 192.168.1.193:/opt/git/mygit
[root@ git]# git push origin master //把自己的修改提交给服务器
Counting objects: 3, done.
Writing objects: 100% (3/3), 221 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To 192.168.1.193:/opt/git/mygit
* [new branch] master -> master
第三:关于权限的设定
这里设置只有有权限的人可以浏览修改,其他人不可以
[root@ ~]# useradd git
[root@ ~]# vim /etc/passwd
git:x:501:501::/home/git:/bin/bash/git-shell
这样就可以了
总结:git学习笔记。