GitHub Pull requests
以廖雪峰老师的仓库举例
fork
想修改的仓库
fork
成功
- 本地
clone
$ git clone git@github.com:michaelliao/learngit.git
Cloning into 'learngit'...
remote: Enumerating objects: 11673, done.
remote: Counting objects: 100% (118/118), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 11673 (delta 52), reused 93 (delta 37), pack-reused 11555
Receiving objects: 100% (11673/11673), 3.16 MiB | 17.00 KiB/s, done.
Resolving deltas: 100% (5267/5267), done.
Updating files: 100% (1028/1028), done.
- 按照仓库主的要求,提交修改,并上传到自己的远程仓库
$ git add .
$ git commit -m "add prLearn.md"
[master 5e62e0b] add prLearn.md
1 file changed, 396 insertions(+)
create mode 100644 2022-07/prLearn.md
$ git remote add my git@github.com:taroandpuff/learngit.git
需要上传到自己的远程仓库去,所以需要关联自己的远程仓库
$ git push my master
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 16 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 4.28 KiB | 4.28 MiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:taroandpuff/learngit.git
97f0e30..5e62e0b master -> master
- 在自己的
Github
仓库页面,点pull requests
点new pull request
写必要的合并说明,然后一路点create
就可以等仓库主是否同意合并了
关联多个远程仓库
git remote add [远程仓库别名] <远程仓库URL>
按照要求输入指令即可
Git服务器配置
安装Git
PuTTY
输入指令安装Git
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
$ yum install git
- 创建Git用户组和用户
$ groupadd git
$ useradd git -g git
创建证书登录
- 推荐用
WinSCP
操作
到/home/git/.ssh/中
创建authorized_keys文件
将公钥id_rsa.pub文件内容复制到authorized_keys文件中
初始化Git仓库
- 以菜鸟教程的内容展示
- 首先我们选定一个目录作为Git仓库,假定是/home/gitrepo/runoob.git,在/home/gitrepo目录下输入命令:
$ cd /home
$ mkdir gitrepo
$ chown git:git gitrepo/
$ cd gitrepo
$ git init --bare runoob.git
Initialized empty Git repository in /home/gitrepo/runoob.git/
- 以上命令Git创建一个空仓库,服务器上的Git仓库通常都以.git结尾。然后,把仓库所属用户改为git:
$ chown -R git:git runoob.git
克隆仓库
- 注意将
ip地址
换成自己服务器的ip
$ git clone git@192.168.45.4:/home/gitrepo/runoob.git
Cloning into 'runoob'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
注意点
- 在服务器上,不能像
GitHub
一样操作文件本身,只能看到Git版本库文件 - Git服务器只是为了方便用户交换设置