您的位置:首页 > 运维架构 > Linux

Linux_Git 服务器安装笔记

2017-11-30 18:09 447 查看
环境:Vmware Workstation 10,CentOS-7-x86_64-DVD-1511.iso,Xshell 4.0,ip:192.168.216.140.

[root@localhost ~]# git

-bash: git: 未找到命令

[root@localhost ~]# yum install git

已加载插件:fastestmirror

。。。。

已安装:

git.x86_64 0:1.8.3.1-12.el7_4

作为依赖被安装:

libgnome-keyring.x86_64 0:3.12.0-1.el7 perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-12.el7_4

perl-TermReadKey.x86_64 0:2.30-20.el7 rsync.x86_64 0:3.0.9-18.el7

完毕!

[root@localhost home]# id git

id: git: no such user

[root@localhost home]# useradd git

[root@localhost home]# passwd git

更改用户 git 的密码 。

新的 密码:

重新输入新的 密码:

passwd:所有的身份验证令牌已经成功更新。

[root@localhost ~]# git init - -bare /data/git/test.git

初始化空的 Git 版本库于 /data/git/test.git/

查看仓库所有者

[root@localhost ~]# ll /data/git/

总用量 4

drwxr-xr-x. 7 root root 4096 11月 30 17:12 test.git

[root@localhost ~]# ll /data/git/test.git/

总用量 16

drwxr-xr-x. 2 root root 6 11月 30 17:12 branches

-rw-r–r–. 1 root root 66 11月 30 17:12 config

-rw-r–r–. 1 root root 73 11月 30 17:12 description

-rw-r–r–. 1 root root 23 11月 30 17:12 HEAD

drwxr-xr-x. 2 root root 4096 11月 30 17:12 hooks

drwxr-xr-x. 2 root root 20 11月 30 17:12 info

drwxr-xr-x. 4 root root 28 11月 30 17:12 objects

drwxr-xr-x. 4 root root 29 11月 30 17:12 refs

更换仓库所有者

[root@localhost ~]# chown -R git:git /data/git/

[root@localhost ~]# ll /data/git/

总用量 4

drwxr-xr-x. 7 git git 4096 11月 30 17:12 test.git

[root@localhost ~]# ll /data/git/test.git/

总用量 16

drwxr-xr-x. 2 git git 6 11月 30 17:12 branches

-rw-r–r–. 1 git git 66 11月 30 17:12 config

-rw-r–r–. 1 git git 73 11月 30 17:12 description

-rw-r–r–. 1 git git 23 11月 30 17:12 HEAD

drwxr-xr-x. 2 git git 4096 11月 30 17:12 hooks

drwxr-xr-x. 2 git git 20 11月 30 17:12 info

drwxr-xr-x. 4 git git 28 11月 30 17:12 objects

drwxr-xr-x. 4 git git 29 11月 30 17:12 refs

[root@localhost ~]# vim /etc/ssh/sshd_config

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

在/home/git目录下创建 .ssh/authorized_keys文件

[root@localhost ~]# mkdir /home/git/.ssh && touch /home/git/.ssh/authorized_keys

本地使用cmd创建SSH 公钥和私钥

ssh-keygen -t rsa -C “邮箱地址”

一路默认回车即可,完成后将C:\Users\liu.ssh\id_rsa.pub内容复制到git服务器/home/.ssh/authorized_keys文件中保存。

在本地添加项目,并提交到远端master分支

git.exe push - -progress “origin” master:master



- 创建dev分支



切换到dev分支

git.exe checkout dev - -



- 本地dev分支push到远端dev分支

git.exe push - -progress “origin” dev:dev



本地所有分支



远端所有分支



分支合并,将dev分支合并到master分支









回去查看master分支



仓库迁移本地有一个名为git_demo的仓库

第一步,在服务器端创建一个新的仓库,命名为git_demo.git

[root@localhost ~]# git init - -bare /data/git/git_demo.git

[root@localhost ~]# chown -R git:git /data/git/git_demo.git

第二步,将本地git_demo上传到远端的地址修改为新的地址,让后上传即可

$ git push git@192.168.216.140:/data/git/git_demo.git master:master

Counting objects: 3, done.

Writing objects: 100% (3/3), 210 bytes | 0 bytes/s, done.

Total 3 (delta 0), reused 0 (delta 0)

To git@192.168.216.140:/data/git/git_demo.git

* [new branch] master -> master
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git 分支