CentOS安装Git实现多人同步开发

时间:2022-06-12 12:06:12

描  述

要开发一个”cms系统“,有2个人分别是:晓飞, 盈月。要求使用Git来进行版本控制。

项目信息

版本控制:Git

项目名称:cms

开发人员:xiaofei,yingyue

CentOS安装Git实现多人同步开发

------------------------------------------------------------------------------------------------------------------------------------------------------

概  要

1、服务器上安装Git依赖及Git

2、创建Git用户及所属组

3、安装Git客户端并生成公钥

4、创建证书登录

5、服务器上初始化Git仓库

6、使用Git Bash克隆服务器上的空仓库

7、将本地库项目推送到服务器

8、导入本地Git库的项目到eclipse

------------------------------------------------------------------------------------------------------------------------------------------------------

1、服务器上安装Git依赖及Git

安装Git依赖

注:yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel是一次性安装也可以一个一个安装
[root@localhost zhoujianxu]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
CentOS安装Git实现多人同步开发CentOS安装Git实现多人同步开发
[root@localhost zhoujianxu]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
Loaded plugins: fastestmirror
, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.zju.edu.cn
* updates: ftp.isu.edu.tw
base |
3.7 kB 00:00
extras |
3.3 kB 00:00
updates |
3.4 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package expat-devel.i686
0:2.0.1-11.el6_2 will be installed
---> Package gettext-devel.i686
0:0.17-18.el6 will be installed
--> Processing Dependency: gettext-libs
= 0.17-18.el6 for package: gettext-devel-0.17-18.el6.i686
--> Processing Dependency: gettext
= 0.17-18.el6 for package: gettext-devel-0.17-18.el6.i686
--> Processing Dependency: libgettextsrc-
0.17.so for package: gettext-devel-0.17-18.el6.i686
--> Processing Dependency: libgettextpo.so
.0 for package: gettext-devel-0.17-18.el6.i686
--> Processing Dependency: libgettextlib-
0.17.so for package: gettext-devel-0.17-18.el6.i686
--> Processing Dependency: libgcj_bc.so
.1 for package: gettext-devel-0.17-18.el6.i686
--> Processing Dependency: libasprintf.so
.0 for package: gettext-devel-0.17-18.el6.i686
---> Package libcurl-devel.i686
0:7.19.7-52.el6 will be installed
--> Processing Dependency: libcurl
= 7.19.7-52.el6 for package: libcurl-devel-7.19.7-52.el6.i686
--> Processing Dependency: libidn-devel for package: libcurl-devel-
7.19.7-52.el6.i686
--> Processing Dependency: automake for package: libcurl-devel-
7.19.7-52.el6.i686
---> Package openssl-devel.i686
0:1.0.1e-48.el6_8.3 will be installed
--> Processing Dependency: openssl
= 1.0.1e-48.el6_8.3 for package: openssl-devel-1.0.1e-48.el6_8.3.i686
--> Processing Dependency: krb5-devel for package: openssl-devel-
1.0.1e-48.el6_8.3.i686
---> Package perl-devel.i686
4:5.10.1-141.el6_7.1 will be installed
--> Processing Dependency: perl
= 4:5.10.1-141.el6_7.1 for package: 4:perl-devel-5.10.1-141.el6_7.1.i686
--> Processing Dependency: perl(ExtUtils::ParseXS) for package:
4:perl-devel-5.10.1-141.el6_7.1.i686
--> Processing Dependency: perl(ExtUtils::MakeMaker) for package:
4:perl-devel-5.10.1-141.el6_7.1.i686
--> Processing Dependency: perl(ExtUtils::Installed) for package:
4:perl-devel-5.10.1-141.el6_7.1.i686
--> Processing Dependency: gdbm-devel for package:
4:perl-devel-5.10.1-141.el6_7.1.i686
--> Processing Dependency: db4-devel for package:
4:perl-devel-5.10.1-141.el6_7.1.i686
---> Package zlib-devel.i686
0:1.2.3-29.el6 will be installed
--> Running transaction check
---> Package automake.noarch
0:1.11.1-4.el6 will be installed
--> Processing Dependency: autoconf >
= 2.62 for package: automake-1.11.1-4.el6.noarch
---> Package db4-devel.i686
0:4.7.25-20.el6_7 will be installed
--> Processing Dependency: db4-cxx
= 4.7.25-20.el6_7 for package: db4-devel-4.7.25-20.el6_7.i686
--> Processing Dependency: db4
= 4.7.25-20.el6_7 for package: db4-devel-4.7.25-20.el6_7.i686
--> Processing Dependency: libdb_cxx-
4.7.so for package: db4-devel-4.7.25-20.el6_7.i686
---> Package gdbm-devel.i686
0:1.8.0-39.el6 will be installed
--> Processing Dependency: gdbm
= 1.8.0-39.el6 for package: gdbm-devel-1.8.0-39.el6.i686
---> Package gettext.i686
0:0.17-18.el6 will be installed
--> Processing Dependency: cvs for package: gettext-
0.17-18.el6.i686
---> Package gettext-libs.i686
0:0.17-18.el6 will be installed
---> Package krb5-devel.i686
0:1.10.3-57.el6 will be installed
--> Processing Dependency: krb5-libs
= 1.10.3-57.el6 for package: krb5-devel-1.10.3-57.el6.i686
--> Processing Dependency: libselinux-devel for package: krb5-devel-
1.10.3-57.el6.i686
--> Processing Dependency: libcom_err-devel for package: krb5-devel-
1.10.3-57.el6.i686
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-
1.10.3-57.el6.i686
---> Package libcurl.i686
0:7.19.7-35.el6 will be updated
--> Processing Dependency: libcurl
= 7.19.7-35.el6 for package: curl-7.19.7-35.el6.i686
---> Package libcurl.i686
0:7.19.7-52.el6 will be an update
---> Package libgcj.i686
0:4.4.7-17.el6 will be installed
---> Package libidn-devel.i686
0:1.18-2.el6 will be installed
---> Package openssl.i686
0:1.0.0-27.el6 will be updated
---> Package openssl.i686
0:1.0.1e-48.el6_8.3 will be an update
---> Package perl.i686
4:5.10.1-129.el6 will be updated
--> Processing Dependency: perl
= 4:5.10.1-129.el6 for package: 1:perl-Pod-Simple-3.13-129.el6.i686
--> Processing Dependency: perl
= 4:5.10.1-129.el6 for package: 3:perl-version-0.77-129.el6.i686
--> Processing Dependency: perl
= 4:5.10.1-129.el6 for package: 4:perl-libs-5.10.1-129.el6.i686
--> Processing Dependency: perl
= 4:5.10.1-129.el6 for package: 1:perl-Module-Pluggable-3.90-129.el6.i686
--> Processing Dependency: perl
= 4:5.10.1-129.el6 for package: 1:perl-Pod-Escapes-1.04-129.el6.i686
---> Package perl.i686
4:5.10.1-141.el6_7.1 will be an update
---> Package perl-ExtUtils-MakeMaker.i686
0:6.55-141.el6_7.1 will be installed
--> Processing Dependency: perl(Test::Harness) for package: perl-ExtUtils-MakeMaker-
6.55-141.el6_7.1.i686
---> Package perl-ExtUtils-ParseXS.i686
1:2.2003.0-141.el6_7.1 will be installed
--> Running transaction check
---> Package autoconf.noarch
0:2.63-5.1.el6 will be installed
---> Package curl.i686
0:7.19.7-35.el6 will be updated
---> Package curl.i686
0:7.19.7-52.el6 will be an update
---> Package cvs.i686
0:1.11.23-16.el6 will be installed
---> Package db4.i686
0:4.7.25-17.el6 will be updated
--> Processing Dependency: db4
= 4.7.25-17.el6 for package: db4-utils-4.7.25-17.el6.i686
---> Package db4.i686
0:4.7.25-20.el6_7 will be an update
---> Package db4-cxx.i686
0:4.7.25-20.el6_7 will be installed
---> Package gdbm.i686
0:1.8.0-36.el6 will be updated
---> Package gdbm.i686
0:1.8.0-39.el6 will be an update
---> Package keyutils-libs-devel.i686
0:1.4-5.el6 will be installed
--> Processing Dependency: keyutils-libs
= 1.4-5.el6 for package: keyutils-libs-devel-1.4-5.el6.i686
---> Package krb5-libs.i686
0:1.10.3-10.el6 will be updated
---> Package krb5-libs.i686
0:1.10.3-57.el6 will be an update
---> Package libcom_err-devel.i686
0:1.41.12-22.el6 will be installed
--> Processing Dependency: libcom_err
= 1.41.12-22.el6 for package: libcom_err-devel-1.41.12-22.el6.i686
---> Package libselinux-devel.i686
0:2.0.94-7.el6 will be installed
--> Processing Dependency: libselinux
= 2.0.94-7.el6 for package: libselinux-devel-2.0.94-7.el6.i686
--> Processing Dependency: libsepol-devel >
= 2.0.32-1 for package: libselinux-devel-2.0.94-7.el6.i686
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-
2.0.94-7.el6.i686
---> Package perl-Module-Pluggable.i686
1:3.90-129.el6 will be updated
---> Package perl-Module-Pluggable.i686
1:3.90-141.el6_7.1 will be an update
---> Package perl-Pod-Escapes.i686
1:1.04-129.el6 will be updated
---> Package perl-Pod-Escapes.i686
1:1.04-141.el6_7.1 will be an update
---> Package perl-Pod-Simple.i686
1:3.13-129.el6 will be updated
---> Package perl-Pod-Simple.i686
1:3.13-141.el6_7.1 will be an update
---> Package perl-Test-Harness.i686
0:3.17-141.el6_7.1 will be installed
---> Package perl-libs.i686
4:5.10.1-129.el6 will be updated
---> Package perl-libs.i686
4:5.10.1-141.el6_7.1 will be an update
---> Package perl-version.i686
3:0.77-129.el6 will be updated
---> Package perl-version.i686
3:0.77-141.el6_7.1 will be an update
--> Running transaction check
---> Package db4-utils.i686
0:4.7.25-17.el6 will be updated
---> Package db4-utils.i686
0:4.7.25-20.el6_7 will be an update
---> Package keyutils-libs.i686
0:1.4-4.el6 will be updated
---> Package keyutils-libs.i686
0:1.4-5.el6 will be an update
---> Package libcom_err.i686
0:1.41.12-14.el6 will be updated
--> Processing Dependency: libcom_err
= 1.41.12-14.el6 for package: libss-1.41.12-14.el6.i686
--> Processing Dependency: libcom_err
= 1.41.12-14.el6 for package: e2fsprogs-libs-1.41.12-14.el6.i686
--> Processing Dependency: libcom_err
= 1.41.12-14.el6 for package: e2fsprogs-1.41.12-14.el6.i686
---> Package libcom_err.i686
0:1.41.12-22.el6 will be an update
---> Package libselinux.i686
0:2.0.94-5.3.el6 will be updated
--> Processing Dependency: libselinux
= 2.0.94-5.3.el6 for package: libselinux-utils-2.0.94-5.3.el6.i686
--> Processing Dependency: libselinux
= 2.0.94-5.3.el6 for package: libselinux-python-2.0.94-5.3.el6.i686
---> Package libselinux.i686
0:2.0.94-7.el6 will be an update
---> Package libsepol-devel.i686
0:2.0.41-4.el6 will be installed
--> Running transaction check
---> Package e2fsprogs.i686
0:1.41.12-14.el6 will be updated
---> Package e2fsprogs.i686
0:1.41.12-22.el6 will be an update
---> Package e2fsprogs-libs.i686
0:1.41.12-14.el6 will be updated
---> Package e2fsprogs-libs.i686
0:1.41.12-22.el6 will be an update
---> Package libselinux-python.i686
0:2.0.94-5.3.el6 will be updated
---> Package libselinux-python.i686
0:2.0.94-7.el6 will be an update
---> Package libselinux-utils.i686
0:2.0.94-5.3.el6 will be updated
---> Package libselinux-utils.i686
0:2.0.94-7.el6 will be an update
---> Package libss.i686
0:1.41.12-14.el6 will be updated
---> Package libss.i686
0:1.41.12-22.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
expat-devel i686
2.0.1-11.el6_2 base 121 k
gettext-devel i686
0.17-18.el6 base 154 k
libcurl-devel i686
7.19.7-52.el6 base 247 k
openssl-devel i686
1.0.1e-48.el6_8.3 updates 1.2 M
perl-devel i686
4:5.10.1-141.el6_7.1 base 424 k
zlib-devel i686
1.2.3-29.el6 base 44 k
Installing for dependencies:
autoconf noarch
2.63-5.1.el6 base 781 k
automake noarch
1.11.1-4.el6 base 550 k
cvs i686
1.11.23-16.el6 base 699 k
db4-cxx i686
4.7.25-20.el6_7 base 606 k
db4-devel i686
4.7.25-20.el6_7 base 6.6 M
gdbm-devel i686
1.8.0-39.el6 base 26 k
gettext i686
0.17-18.el6 base 1.8 M
gettext-libs i686
0.17-18.el6 base 110 k
keyutils-libs-devel i686
1.4-5.el6 base 29 k
krb5-devel i686
1.10.3-57.el6 base 503 k
libcom_err-devel i686
1.41.12-22.el6 base 32 k
libgcj i686
4.4.7-17.el6 base 17 M
libidn-devel i686
1.18-2.el6 base 137 k
libselinux-devel i686
2.0.94-7.el6 base 137 k
libsepol-devel i686
2.0.41-4.el6 base 64 k
perl-ExtUtils-MakeMaker i686
6.55-141.el6_7.1 base 294 k
perl-ExtUtils-ParseXS i686
1:2.2003.0-141.el6_7.1 base 46 k
perl-Test-Harness i686
3.17-141.el6_7.1 base 232 k
Updating for dependencies:
curl i686
7.19.7-52.el6 base 197 k
db4 i686
4.7.25-20.el6_7 base 580 k
db4-utils i686
4.7.25-20.el6_7 base 129 k
e2fsprogs i686
1.41.12-22.el6 base 555 k
e2fsprogs-libs i686
1.41.12-22.el6 base 128 k
gdbm i686
1.8.0-39.el6 base 29 k
keyutils-libs i686
1.4-5.el6 base 20 k
krb5-libs i686
1.10.3-57.el6 base 778 k
libcom_err i686
1.41.12-22.el6 base 37 k
libcurl i686
7.19.7-52.el6 base 176 k
libselinux i686
2.0.94-7.el6 base 109 k
libselinux-python i686
2.0.94-7.el6 base 200 k
libselinux-utils i686
2.0.94-7.el6 base 82 k
libss i686
1.41.12-22.el6 base 42 k
openssl i686
1.0.1e-48.el6_8.3 updates 1.5 M
perl i686
4:5.10.1-141.el6_7.1 base 9.7 M
perl-Module-Pluggable i686
1:3.90-141.el6_7.1 base 40 k
perl-Pod-Escapes i686
1:1.04-141.el6_7.1 base 33 k
perl-Pod-Simple i686
1:3.13-141.el6_7.1 base 213 k
perl-libs i686
4:5.10.1-141.el6_7.1 base 594 k
perl-version i686
3:0.77-141.el6_7.1 base 52 k

Transaction Summary
========================================================================================
Install
24 Package(s)
Upgrade
21 Package(s)

Total download size:
47 M
Is this ok
[y/N]: y
Downloading Packages:
(
1/45): autoconf-2.63-5.1.el6.noarch.rpm | 781 kB 00:01
(
2/45): automake-1.11.1-4.el6.noarch.rpm | 550 kB 00:00
(
3/45): curl-7.19.7-52.el6.i686.rpm | 197 kB 00:00
(
4/45): cvs-1.11.23-16.el6.i686.rpm | 699 kB 00:01
(
5/45): db4-4.7.25-20.el6_7.i686.rpm | 580 kB 00:00
(
6/45): db4-cxx-4.7.25-20.el6_7.i686.rpm | 606 kB 00:00
(
7/45): db4-devel-4.7.25-20.el6_7.i686.rpm | 6.6 MB 00:10
(
8/45): db4-utils-4.7.25-20.el6_7.i686.rpm | 129 kB 00:00
(
9/45): e2fsprogs-1.41.12-22.el6.i686.rpm | 555 kB 00:00
(
10/45): e2fsprogs-libs-1.41.12-22.el6.i686.rpm | 128 kB 00:00
(
11/45): expat-devel-2.0.1-11.el6_2.i686.rpm | 121 kB 00:00
(
12/45): gdbm-1.8.0-39.el6.i686.rpm | 29 kB 00:00
(
13/45): gdbm-devel-1.8.0-39.el6.i686.rpm | 26 kB 00:00
(
14/45): gettext-0.17-18.el6.i686.rpm | 1.8 MB 00:02
(
15/45): gettext-devel-0.17-18.el6.i686.rpm | 154 kB 00:00
(
16/45): gettext-libs-0.17-18.el6.i686.rpm | 110 kB 00:00
(
17/45): keyutils-libs-1.4-5.el6.i686.rpm | 20 kB 00:00
(
18/45): keyutils-libs-devel-1.4-5.el6.i686.rpm | 29 kB 00:00
(
19/45): krb5-devel-1.10.3-57.el6.i686.rpm | 503 kB 00:00
(
20/45): krb5-libs-1.10.3-57.el6.i686.rpm | 778 kB 00:01
(
21/45): libcom_err-1.41.12-22.el6.i686.rpm | 37 kB 00:00
(
22/45): libcom_err-devel-1.41.12-22.el6.i686.rpm | 32 kB 00:00
(
23/45): libcurl-7.19.7-52.el6.i686.rpm | 176 kB 00:00
(
24/45): libcurl-devel-7.19.7-52.el6.i686.rpm | 247 kB 00:00
(
25/45): libgcj-4.4.7-17.el6.i686.rpm | 17 MB 00:28
(
26/45): libidn-devel-1.18-2.el6.i686.rpm | 137 kB 00:00
(
27/45): libselinux-2.0.94-7.el6.i686.rpm | 109 kB 00:00
(
28/45): libselinux-devel-2.0.94-7.el6.i686.rpm | 137 kB 00:00
(
29/45): libselinux-python-2.0.94-7.el6.i686.rpm | 200 kB 00:00
(
30/45): libselinux-utils-2.0.94-7.el6.i686.rpm | 82 kB 00:00
(
31/45): libsepol-devel-2.0.41-4.el6.i686.rpm | 64 kB 00:00
(
32/45): libss-1.41.12-22.el6.i686.rpm | 42 kB 00:00
(
33/45): openssl-1.0.1e-48.el6_8.3.i686.rpm | 1.5 MB 01:17
(
34/45): openssl-devel-1.0.1e-48.el6_8.3.i686.rpm | 1.2 MB 01:07
(
35/45): perl-5.10.1-141.el6_7.1.i686.rpm | 9.7 MB 00:15
(
36/45): perl-ExtUtils-MakeMaker-6.55-141.el6_7.1.i686.rpm | 294 kB 00:00
(
37/45): perl-ExtUtils-ParseXS-2.2003.0-141.el6_7.1.i686.rpm | 46 kB 00:00
(
38/45): perl-Module-Pluggable-3.90-141.el6_7.1.i686.rpm | 40 kB 00:00
(
39/45): perl-Pod-Escapes-1.04-141.el6_7.1.i686.rpm | 33 kB 00:00
(
40/45): perl-Pod-Simple-3.13-141.el6_7.1.i686.rpm | 213 kB 00:00
(
41/45): perl-Test-Harness-3.17-141.el6_7.1.i686.rpm | 232 kB 00:00
(
42/45): perl-devel-5.10.1-141.el6_7.1.i686.rpm | 424 kB 00:00
(
43/45): perl-libs-5.10.1-141.el6_7.1.i686.rpm | 594 kB 00:00
(
44/45): perl-version-0.77-141.el6_7.1.i686.rpm | 52 kB 00:00
(
45/45): zlib-devel-1.2.3-29.el6.i686.rpm | 44 kB 00:00
----------------------------------------------------------------------------------------
Total
218 kB/s | 47 MB 03:41
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libcom_err-
1.41.12-22.el6.i686 1/66
Updating : libselinux-
2.0.94-7.el6.i686 2/66
Updating : db4-
4.7.25-20.el6_7.i686 3/66
Updating : keyutils-libs-
1.4-5.el6.i686 4/66
Installing : keyutils-libs-devel-
1.4-5.el6.i686 5/66
Installing : libcom_err-devel-
1.41.12-22.el6.i686 6/66
Installing : libidn-devel-
1.18-2.el6.i686 7/66
Installing : zlib-devel-
1.2.3-29.el6.i686 8/66
Installing : libsepol-devel-
2.0.41-4.el6.i686 9/66
Updating : krb5-libs-
1.10.3-57.el6.i686 10/66
Updating : libcurl-
7.19.7-52.el6.i686 11/66
Updating : gdbm-
1.8.0-39.el6.i686 12/66
Installing : gdbm-devel-
1.8.0-39.el6.i686 13/66
Installing : libselinux-devel-
2.0.94-7.el6.i686 14/66
Updating :
1:perl-Pod-Escapes-1.04-141.el6_7.1.i686 15/66
Updating :
4:perl-libs-5.10.1-141.el6_7.1.i686 16/66
Updating :
1:perl-Module-Pluggable-3.90-141.el6_7.1.i686 17/66
Updating :
3:perl-version-0.77-141.el6_7.1.i686 18/66
Updating :
1:perl-Pod-Simple-3.13-141.el6_7.1.i686 19/66
Updating :
4:perl-5.10.1-141.el6_7.1.i686 20/66
Installing : autoconf-
2.63-5.1.el6.noarch 21/66
Installing : automake-
1.11.1-4.el6.noarch 22/66
Installing : cvs-
1.11.23-16.el6.i686 23/66
Installing : gettext-
0.17-18.el6.i686 24/66
Installing : krb5-devel-
1.10.3-57.el6.i686 25/66
Updating : openssl-
1.0.1e-48.el6_8.3.i686 26/66
Updating : e2fsprogs-libs-
1.41.12-22.el6.i686 27/66
Updating : libss-
1.41.12-22.el6.i686 28/66
Installing : db4-cxx-
4.7.25-20.el6_7.i686 29/66
Installing : db4-devel-
4.7.25-20.el6_7.i686 30/66
Installing : perl-Test-Harness-
3.17-141.el6_7.1.i686 31/66
Installing : perl-ExtUtils-MakeMaker-
6.55-141.el6_7.1.i686 32/66
Installing :
4:perl-devel-5.10.1-141.el6_7.1.i686 33/66
Installing :
1:perl-ExtUtils-ParseXS-2.2003.0-141.el6_7.1.i686 34/66
Installing : libgcj-
4.4.7-17.el6.i686 35/66
Installing : gettext-libs-
0.17-18.el6.i686 36/66
Installing : openssl-devel-
1.0.1e-48.el6_8.3.i686 37/66
Installing : libcurl-devel-
7.19.7-52.el6.i686 38/66
Installing : expat-devel-
2.0.1-11.el6_2.i686 39/66
Installing : gettext-devel-
0.17-18.el6.i686 40/66
Updating : e2fsprogs-
1.41.12-22.el6.i686 41/66
Updating : curl-
7.19.7-52.el6.i686 42/66
Updating : db4-utils-
4.7.25-20.el6_7.i686 43/66
Updating : libselinux-python-
2.0.94-7.el6.i686 44/66
Updating : libselinux-utils-
2.0.94-7.el6.i686 45/66
Cleanup : e2fsprogs-
1.41.12-14.el6.i686 46/66
Cleanup :
1:perl-Pod-Escapes-1.04-129.el6.i686 47/66
Cleanup :
1:perl-Module-Pluggable-3.90-129.el6.i686 48/66
Cleanup :
3:perl-version-0.77-129.el6.i686 49/66
Cleanup :
4:perl-libs-5.10.1-129.el6.i686 50/66
Cleanup :
4:perl-5.10.1-129.el6.i686 51/66
Cleanup :
1:perl-Pod-Simple-3.13-129.el6.i686 52/66
Cleanup : curl-
7.19.7-35.el6.i686 53/66
Cleanup : libcurl-
7.19.7-35.el6.i686 54/66
Cleanup : openssl-
1.0.0-27.el6.i686 55/66
Cleanup : krb5-libs-
1.10.3-10.el6.i686 56/66
Cleanup : e2fsprogs-libs-
1.41.12-14.el6.i686 57/66
Cleanup : libss-
1.41.12-14.el6.i686 58/66
Cleanup : libselinux-utils-
2.0.94-5.3.el6.i686 59/66
Cleanup : libselinux-python-
2.0.94-5.3.el6.i686 60/66
Cleanup : db4-utils-
4.7.25-17.el6.i686 61/66
Cleanup : db4-
4.7.25-17.el6.i686 62/66
Cleanup : libselinux-
2.0.94-5.3.el6.i686 63/66
Cleanup : libcom_err-
1.41.12-14.el6.i686 64/66
Cleanup : keyutils-libs-
1.4-4.el6.i686 65/66
Cleanup : gdbm-
1.8.0-36.el6.i686 66/66
Verifying : cvs-
1.11.23-16.el6.i686 1/66
Verifying :
1:perl-ExtUtils-ParseXS-2.2003.0-141.el6_7.1.i686 2/66
Verifying : gettext-
0.17-18.el6.i686 3/66
Verifying : curl-
7.19.7-52.el6.i686 4/66
Verifying : keyutils-libs-devel-
1.4-5.el6.i686 5/66
Verifying : openssl-devel-
1.0.1e-48.el6_8.3.i686 6/66
Verifying : keyutils-libs-
1.4-5.el6.i686 7/66
Verifying :
1:perl-Pod-Simple-3.13-141.el6_7.1.i686 8/66
Verifying :
4:perl-libs-5.10.1-141.el6_7.1.i686 9/66
Verifying : libcom_err-
1.41.12-22.el6.i686 10/66
Verifying : db4-devel-
4.7.25-20.el6_7.i686 11/66
Verifying : automake-
1.11.1-4.el6.noarch 12/66
Verifying : libsepol-devel-
2.0.41-4.el6.i686 13/66
Verifying : libselinux-
2.0.94-7.el6.i686 14/66
Verifying : gdbm-devel-
1.8.0-39.el6.i686 15/66
Verifying : libcom_err-devel-
1.41.12-22.el6.i686 16/66
Verifying : gdbm-
1.8.0-39.el6.i686 17/66
Verifying :
4:perl-devel-5.10.1-141.el6_7.1.i686 18/66
Verifying :
1:perl-Module-Pluggable-3.90-141.el6_7.1.i686 19/66
Verifying : db4-utils-
4.7.25-20.el6_7.i686 20/66
Verifying : zlib-devel-
1.2.3-29.el6.i686 21/66
Verifying : libselinux-python-
2.0.94-7.el6.i686 22/66
Verifying : gettext-libs-
0.17-18.el6.i686 23/66
Verifying :
4:perl-5.10.1-141.el6_7.1.i686 24/66
Verifying : autoconf-
2.63-5.1.el6.noarch 25/66
Verifying : e2fsprogs-
1.41.12-22.el6.i686 26/66
Verifying : libidn-devel-
1.18-2.el6.i686 27/66
Verifying : libselinux-devel-
2.0.94-7.el6.i686 28/66
Verifying : libselinux-utils-
2.0.94-7.el6.i686 29/66
Verifying : libgcj-
4.4.7-17.el6.i686 30/66
Verifying : perl-Test-Harness-
3.17-141.el6_7.1.i686 31/66
Verifying : e2fsprogs-libs-
1.41.12-22.el6.i686 32/66
Verifying : db4-cxx-
4.7.25-20.el6_7.i686 33/66
Verifying : perl-ExtUtils-MakeMaker-
6.55-141.el6_7.1.i686 34/66
Verifying : krb5-libs-
1.10.3-57.el6.i686 35/66
Verifying : krb5-devel-
1.10.3-57.el6.i686 36/66
Verifying : gettext-devel-
0.17-18.el6.i686 37/66
Verifying : libss-
1.41.12-22.el6.i686 38/66
Verifying : libcurl-devel-
7.19.7-52.el6.i686 39/66
Verifying : openssl-
1.0.1e-48.el6_8.3.i686 40/66
Verifying : db4-
4.7.25-20.el6_7.i686 41/66
Verifying : libcurl-
7.19.7-52.el6.i686 42/66
Verifying : expat-devel-
2.0.1-11.el6_2.i686 43/66
Verifying :
1:perl-Pod-Escapes-1.04-141.el6_7.1.i686 44/66
Verifying :
3:perl-version-0.77-141.el6_7.1.i686 45/66
Verifying :
3:perl-version-0.77-129.el6.i686 46/66
Verifying : gdbm-
1.8.0-36.el6.i686 47/66
Verifying : openssl-
1.0.0-27.el6.i686 48/66
Verifying : e2fsprogs-
1.41.12-14.el6.i686 49/66
Verifying : db4-utils-
4.7.25-17.el6.i686 50/66
Verifying : keyutils-libs-
1.4-4.el6.i686 51/66
Verifying :
4:perl-libs-5.10.1-129.el6.i686 52/66
Verifying : libss-
1.41.12-14.el6.i686 53/66
Verifying : libselinux-
2.0.94-5.3.el6.i686 54/66
Verifying : e2fsprogs-libs-
1.41.12-14.el6.i686 55/66
Verifying : curl-
7.19.7-35.el6.i686 56/66
Verifying :
1:perl-Pod-Escapes-1.04-129.el6.i686 57/66
Verifying : libselinux-utils-
2.0.94-5.3.el6.i686 58/66
Verifying : libselinux-python-
2.0.94-5.3.el6.i686 59/66
Verifying : libcom_err-
1.41.12-14.el6.i686 60/66
Verifying : krb5-libs-
1.10.3-10.el6.i686 61/66
Verifying :
1:perl-Module-Pluggable-3.90-129.el6.i686 62/66
Verifying : db4-
4.7.25-17.el6.i686 63/66
Verifying : libcurl-
7.19.7-35.el6.i686 64/66
Verifying :
4:perl-5.10.1-129.el6.i686 65/66
Verifying :
1:perl-Pod-Simple-3.13-129.el6.i686 66/66

Installed:
expat-devel.i686
0:2.0.1-11.el6_2 gettext-devel.i686 0:0.17-18.el6
libcurl-devel.i686
0:7.19.7-52.el6 openssl-devel.i686 0:1.0.1e-48.el6_8.3
perl-devel.i686
4:5.10.1-141.el6_7.1 zlib-devel.i686 0:1.2.3-29.el6

Dependency Installed:
autoconf.noarch
0:2.63-5.1.el6
automake.noarch
0:1.11.1-4.el6
cvs.i686
0:1.11.23-16.el6
db4-cxx.i686
0:4.7.25-20.el6_7
db4-devel.i686
0:4.7.25-20.el6_7
gdbm-devel.i686
0:1.8.0-39.el6
gettext.i686
0:0.17-18.el6
gettext-libs.i686
0:0.17-18.el6
keyutils-libs-devel.i686
0:1.4-5.el6
krb5-devel.i686
0:1.10.3-57.el6
libcom_err-devel.i686
0:1.41.12-22.el6
libgcj.i686
0:4.4.7-17.el6
libidn-devel.i686
0:1.18-2.el6
libselinux-devel.i686
0:2.0.94-7.el6
libsepol-devel.i686
0:2.0.41-4.el6
perl-ExtUtils-MakeMaker.i686
0:6.55-141.el6_7.1
perl-ExtUtils-ParseXS.i686
1:2.2003.0-141.el6_7.1
perl-Test-Harness.i686
0:3.17-141.el6_7.1

Dependency Updated:
curl.i686
0:7.19.7-52.el6
db4.i686
0:4.7.25-20.el6_7
db4-utils.i686
0:4.7.25-20.el6_7
e2fsprogs.i686
0:1.41.12-22.el6
e2fsprogs-libs.i686
0:1.41.12-22.el6
gdbm.i686
0:1.8.0-39.el6
keyutils-libs.i686
0:1.4-5.el6
krb5-libs.i686
0:1.10.3-57.el6
libcom_err.i686
0:1.41.12-22.el6
libcurl.i686
0:7.19.7-52.el6
libselinux.i686
0:2.0.94-7.el6
libselinux-python.i686
0:2.0.94-7.el6
libselinux-utils.i686
0:2.0.94-7.el6
libss.i686
0:1.41.12-22.el6
openssl.i686
0:1.0.1e-48.el6_8.3
perl.i686
4:5.10.1-141.el6_7.1
perl-Module-Pluggable.i686
1:3.90-141.el6_7.1
perl-Pod-Escapes.i686
1:1.04-141.el6_7.1
perl-Pod-Simple.i686
1:3.13-141.el6_7.1
perl-libs.i686
4:5.10.1-141.el6_7.1
perl-version.i686
3:0.77-141.el6_7.1

Complete!
[root@localhost zhoujianxu]#
执行过程

安装Git

 如果不知道你要安装包的具体名称,可以使用yum provides */name 进行查找系统自带软件包的信息(这一步不是必须);

   [root@localhost zhoujianxu]# yum provides */git

[root@localhost zhoujianxu]# yum provides */git
Loaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: ftp.sjtu.edu.cn
* updates: ftp.ksu.edu.tw
git-
1.7.1-4.el6_7.1.i686 : Fast Version Control System
Repo : base
Matched from:
Filename : /etc/bash_completion.d/git
Filename : /usr/libexec/git-core/git
Filename : /usr/bin/git

gitweb-
1.7.1-4.el6_7.1.noarch : Simple web interface to git repositories
Repo : base
Matched from:
Filename : /var/www/git

git-daemon-
1.7.1-4.el6_7.1.i686 : Git protocol dæmon
Repo : base
Matched from:
Filename : /var/lib/git
Filename : /etc/xinetd.d/git

emacs-git-
1.7.1-4.el6_7.1.noarch : Git version control system support for Emacs
Repo : base
Matched from:
Filename : /usr/share/emacs/site-lisp/git

[root@localhost zhoujianxu]#

  安装git 执行命令 yum install -y git (-y表示安装过程中不需要手动确认可以不加那么安装过程中需要输入y手动回车确认)

  [root@localhost zhoujianxu]# yum install -y git

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: ftp.sjtu.edu.cn
* updates: ftp.ksu.edu.tw
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.i686
0:1.7.1-4.el6_7.1 will be installed
--> Processing Dependency: perl-Git
= 1.7.1-4.el6_7.1 for package: git-1.7.1-4.el6_7.1.i686
--> Processing Dependency: perl(Git) for package: git-
1.7.1-4.el6_7.1.i686
--> Processing Dependency: perl(Error) for package: git-
1.7.1-4.el6_7.1.i686
--> Processing Dependency: libssl.so
.10(libssl.so.10) for package: git-1.7.1-4.el6_7.1.i686
--> Processing Dependency: libcrypto.so
.10(libcrypto.so.10) for package: git-1.7.1-4.el6_7.1.i686
--> Running transaction check
---> Package openssl.i686
0:1.0.0-27.el6 will be updated
---> Package openssl.i686
0:1.0.1e-48.el6_8.3 will be an update
---> Package perl-Error.noarch
1:0.17015-4.el6 will be installed
---> Package perl-Git.noarch
0:1.7.1-4.el6_7.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
git i686
1.7.1-4.el6_7.1 base 4.5 M
Installing for dependencies:
perl-Error noarch
1:0.17015-4.el6 base 29 k
perl-Git noarch
1.7.1-4.el6_7.1 base 28 k
Updating for dependencies:
openssl i686
1.0.1e-48.el6_8.3 updates 1.5 M

Transaction Summary
========================================================================================
Install
3 Package(s)
Upgrade
1 Package(s)

Total download size:
6.1 M
Downloading Packages:
(
1/4): git-1.7.1-4.el6_7.1.i686.rpm | 4.5 MB 00:16
(
2/4): openssl-1.0.1e-48.el6_8.3.i686.rpm | 1.5 MB 01:29
(
3/4): perl-Error-0.17015-4.el6.noarch.rpm | 29 kB 00:00
(
4/4): perl-Git-1.7.1-4.el6_7.1.noarch.rpm | 28 kB 00:00
----------------------------------------------------------------------------------------
Total
51 kB/s | 6.1 MB 02:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing :
1:perl-Error-0.17015-4.el6.noarch 1/5
Updating : openssl-
1.0.1e-48.el6_8.3.i686 2/5
Installing : git-
1.7.1-4.el6_7.1.i686 3/5
Installing : perl-Git-
1.7.1-4.el6_7.1.noarch 4/5
Cleanup : openssl-
1.0.0-27.el6.i686 5/5
Verifying : perl-Git-
1.7.1-4.el6_7.1.noarch 1/5
Verifying :
1:perl-Error-0.17015-4.el6.noarch 2/5
Verifying : openssl-
1.0.1e-48.el6_8.3.i686 3/5
Verifying : git-
1.7.1-4.el6_7.1.i686 4/5
Verifying : openssl-
1.0.0-27.el6.i686 5/5

Installed:
git.i686
0:1.7.1-4.el6_7.1

Dependency Installed:
perl-Error.noarch
1:0.17015-4.el6 perl-Git.noarch 0:1.7.1-4.el6_7.1

Dependency Updated:
openssl.i686
0:1.0.1e-48.el6_8.3

Complete!
[root@localhost zhoujianxu]#

完成;

2、创建”用户组“和”用户“,用来运行git服务。

 创建用户组

   [root@localhost zhoujianxu]# groupadd java_team

  创建用户并yingyue添加到名为”java_team“的组中

   [root@localhost zhoujianxu]# adduser yingyue -g java_team

   为用户名为yingyue的用户设置密码

 [root@localhost zhoujianxu]# passwd yingyue
   Changing password for user git.
   New password:
   Retype new password:
   passwd: all authentication tokens updated successfully.
   [root@localhost zhoujianxu]#

   创建第二个用户xiaofei

   [root@localhost zhoujianxu]# groupadd java_team

  xiaofei”java_team“的组中

   [root@localhost zhoujianxu]# adduser xiaofei -java_team

   [root@localhost zhoujianxu]# passwd xiaofei

   Changing password for user xiaofei.
   New password: 
   Retype new password: 
   passwd: all authentication tokens updated successfully.
   [root@localhost zhoujianxu]#

3、安装Git客户端并生成公钥:

安装Git客户端(开发人员安装)

下载地址https://git-scm.com/downloads 目前最新版本为:Git-2.10.2-64-bit.exe

CentOS安装Git实现多人同步开发

生成公钥

方式一:图形界面Git GUI方式

右键Git GUI here

 CentOS安装Git实现多人同步开发

点击Help--》Generate Key生成SSHkey

 CentOS安装Git实现多人同步开发

如下

CentOS安装Git实现多人同步开发

这时.ssh目录下就有了公钥(id_rsa.pub)和私钥(id_rsa)

CentOS安装Git实现多人同步开发

方式二:使用Git Bash通过ssh-keygen命令生成, ssh-keygen -t rsa   参数-t rsa 意思是以rsa的加密方式生成秘钥对, 不是必须。

打开Git Bash进入.ssh目录如果没有可以手动建

CentOS安装Git实现多人同步开发

4、创建证书登录

4.1、在用户yingyue.ssh目录下创建authorized_keys文件

收集所有需要登录的用户的公钥,公钥位于id_rsa.pub文件中,把我们的公钥导入到/home/yingyue/.ssh/authorized_keys文件里,一行一个。

如果没有该文件创建它(.ssh为隐藏文件夹可以使用ls -la 或 ll 命令查看):

[root@localhost zhoujianxu]# cd /home/yingyue/
[root@localhost yingyue]# ls
[root@localhost yingyue]# mkdir .ssh
[root@localhost yingyue]# ls
[root@localhost yingyue]# ls -la
total 32
drwx------. 5 yingyue java_team 4096 Nov 12 22:48 .
drwxr-xr-x. 4 root root 4096 Nov 12 22:12 ..
-rw-r--r--. 1 yingyue java_team 18 Feb 21 2013 .bash_logout
-rw-r--r--. 1 yingyue java_team 176 Feb 21 2013 .bash_profile
-rw-r--r--. 1 yingyue java_team 124 Feb 21 2013 .bashrc
drwxr-xr-x. 2 yingyue java_team 4096 Nov 11 2010 .gnome2
drwxr-xr-x. 4 yingyue java_team 4096 Nov 12 19:25 .mozilla
drwxr-xr-x. 2 root root 4096 Nov 12 22:48 .ssh
[root@localhost yingyue]# chmod 700 .ssh
[root@localhost yingyue]# touch .ssh/authorized_keys
[root@localhost yingyue]# chmod 600 .ssh/authorized_keys
[root@localhost yingyue]#

注:chmod命令详解

在linux系统中,我们经常会通过chmod命令来更改文档所属的权限,格式为:chmod abc file 

其中a,b,c各为一个数字,分别表示User、Group、及Other的权限。

在解释上述命令之前,我们先来了解一下unix系统家族中,对用户权限的划分在yingyue账户下新建一个文件,test.txt 然后我们用ls -a 来查看

[root@localhost yingyue]# ls -la test.txt
drwxr-xr-x.2 root root 0 Nov 14 10:16 test.txt
可以看到,之前有-rwxr-xr-x这样一串字符。第一位为文件类型,之后每三位在一起分别代表用户的权限(User)、组的权限(group)、其他用户的权限(Other)

其结构如下图所示:

CentOS安装Git实现多人同步开发

r=4,w=2,x=1
若要rwx属性则4+2+1=7 
若要rw-属性则4+2=6
若要r-x属性则4+1=5
如下图:

chmod 600 .ssh/authorized_keys 表示只有所属用户对.ssh目录下的authorized_keys具有读写权限没有执行权限,Group和Other没有权限。

CentOS安装Git实现多人同步开发

-rw------- (600) -- 只有属主有读写权限
-rw-r--r-- (644) -- 只有属主有读写权限;而属组用户和其他用户只有读权限。
-rwx------ (700) -- 只有属主有读、写、执行权限。
-rwxr-xr-x (755) -- 属主有读、写、执行权限;而属组用户和其他用户只有读、执行权限。
-rwx--x--x (711) -- 属主有读、写、执行权限;而属组用户和其他用户只有执行权限。
-rw-rw-rw- (666) -- 所有用户都有文件读、写权限。这种做法不可取。
-rwxrwxrwx (777) -- 所有用户都有读、写、执行权限。更不可取的做法。
以下是对目录的两个普通设定:

drwx------ (700) - 只有属主可在目录中读、写。
drwxr-xr-x (755) - 所有用户可读该目录,但只有属主才能改变目录中的内容。

Linux/Unix 的档案调用权限分为三级 : 档案拥有者、群组、其他。利用 chmod 可以藉以控制档案如何被他人所调用。

4.2、将id_rsa_yingyue.pub 公钥添加到authorized_keys文件中

收集所有需要登录的用户(即:开发人员 xiaofei,yingyue)的公钥,把我们的公钥导入到/home/yingyue/.ssh/authorized_keys文件里,一行一个。(注:公钥可以发给管理员管理员通过Xshell或文件传输工具传到服务器通过 vi 或 cat 命令进行合并即可,cat控制台查看  >> 或 tee 表示输入到目标文件中)如下:

将yingyue的公钥添加到authorized_key中:

[root@localhost yingyue]# cat /home/pubkeys/id_rsa_yingyue.pub >> .ssh/authorized_keys

将yingyue的公钥添加到authorized_key中:

[root@localhost xiaofen]# cat /home/pubkeys/id_rsa_xiaofei.pub | tee .ssh/authorized_keys

5、服务器上初始化Git仓库(即:在服务器上创建一个空的仓库

首先选定一个目录作为Git仓库假设是git_respository那么我的想法是这样的这这个文件夹下可以创建多个git仓库通过不同的命名来区分仓库作用。

结构图如下:

CentOS安装Git实现多人同步开发

从上图可知cms项目在cms_repo.git这个库,路径为/home/git_repository/cms_repo.git,下面就在git_repository目录下初始化一个空的仓库cms_repo.git

[root@localhost yingyue]# cd /home
[root@localhost home]# mkdir git_repository
[root@localhost home]# ls
git_repository
[root@localhost home]# chown yingyue:java_team git_repository
[root@localhost home]# cd git_repository/
[root@localhost git_repository]# git init --bare cms_repo.git
Initialized empty Git repository in /home/git_repository/cms_repo.git/
[root@localhost git_repository]# ls
cms_repo.git
[root@localhost git_repository]#

chow 命令详解:

chown将指定文件的拥有者改为指定的用户或组(即:修改文件目录属主),用户可以是用户名或者用户ID;组可以是组名或者组ID;文件是以空格分开的要改变权限的文件列表,支持通配符。系统管理员经常使用chown命令,在将文件拷贝到另一个用户的名录下之后,让用户拥有使用该文件的权限。

  1.命令格式:chown [选项]... [所有者][:[组]] 文件...

  2.命令功能:
    通过chown改变文件的拥有者和群组。在更改文件的所有者或所属群组时,可以使用用户名称和用户识别码设置。普通用户不能将自己的文件改变成其他的拥有者。其操作权限一般为管理员

如下图:

chown yingyue:java_team git_repository 表示将git_repository目录的权限更改为当前所属用户为yingyue所属组为java_team,如下图:

CentOS安装Git实现多人同步开发

chown命令的参数-R表示向下递归改变目录的所属用户和所属组,chown -R yingyue:java_team cms_repo.git 表示将cms_repo.git目录的权限向下递归更改为所属用户为yingyue所属组为java_team。

[root@localhost git_repository]# chown -R yingyue:java_team cms_repo.git
[root@localhost git_repository]#

如下图:

CentOS安装Git实现多人同步开发

这一步很重要

给yingyue对git_repository目录 可读,可写,可执行 的权限;对cms_repo.git目录及子目录 可读,可写,可执行的权限。(rwx用数字7表示)

给xiaofei对cms_repo.git目录及子目录 可读,可写,可执行的权限,xiaofei在java_team里所以该组的权限即可。              ( rwx用数字7表示 )

给其他用户对cms_repo.git目录及子目录 可读 的权限。                              ( r - -用数字4表示 )

chmod 774 -R cms_repo.git

CentOS安装Git实现多人同步开发

 落下一步,将git_repository目录权限改为 yingyue 拥有 可读,可写,可执行 权限;java_team组 拥有 可读,可执行 权限;其他用户没有权限;

chmod 750 git_repository

CentOS安装Git实现多人同步开发

这时用户名为zhoujianxu的用户对git_repository没有任何权限了

CentOS安装Git实现多人同步开发

6、使用Git Bash克隆服务器上的空仓库

仓库地址:git@192.168.42.129:/home/git_repository/cms_repo.git

 现在Git服务器上已经有了空仓库cms_repo.git 那么yingyue想把eclipse中的cms项目传到仓库中,步骤如下:

进入本地磁盘F盘右键Git Bash Here

CentOS安装Git实现多人同步开发

格式git clone [user@]example.com:/*/*.git/

执行 git clone yingyue@192.168.42.129:/home/git_repository/cms_repo.git

CentOS安装Git实现多人同步开发

仓库已经克隆到yingyue的本地磁盘F

CentOS安装Git实现多人同步开发

同时在本地磁盘的.ssh目录下多了个文件known_hosts

CentOS安装Git实现多人同步开发

这个文件是纪录连到对方时,对方给的 host key。每次连线时都会检查目前对方给的 host key 与纪录的 host key 是否相同,可以简单验证连结是否又被诈骗等相关事宜。

注:克隆版本库的时候,所使用的远程主机自动被Git命名为origin。如果想用其他的主机名,需要用git clone命令的-o选项指定(可以使用git remote命令查看,添加,修改,删除远程主机)。

例如:
$ git clone -o jQuery https://github.com/jquery/jquery.git$ git remote
jQuery
表示克隆的时候,指定远程主机叫做jQuery

   git clone支持多种协议,除了HTTP(s)以外,还支持SSH、Git、本地文件协议等,下面是一些例子。

$ git clone http[s]://example.com/*/*/*.git/
$ git clone ssh://example.com/*/*/*.git/
$ git clone git://example.com/*/*/*.git/
$ git clone /opt/git/project.git
$ git clone file:///opt/git/project.git
$ git clone ftp[s]://example.com/*/*/*.git/
$ git clone rsync://example.com/*/*/*.git/

ssh协议还有另一种写法
$ git clone [user@]example.com:*/*/*.git/

来试一下用户zhoujianxu可以克隆吗?上面已经设置设置了对git_repository目录的访问权限,所以zhoujianxu是没法克隆的 如下图;
CentOS安装Git实现多人同步开发

7、将本地库项目推送到服务器

 将eclipse中的cms项目复制到cms_repo目录

CentOS安装Git实现多人同步开发

进入cms_repo目录并查看远程主机名(默认为origin)

CentOS安装Git实现多人同步开发

可以使用git remote rename命令用于远程主机的改名,格式为:

$ git remote rename <原主机名> <新主机名>

 不改了就用默认。

 执行git add .把整个cms项目内文件的信息添加到索引库中,使用git commit命令提交。(git将依据索引库中的内容来进行文件的提交)

CentOS安装Git实现多人同步开发

执行git push -u origin master命令将本地cms_repository库的文件提交到远程服务器

CentOS安装Git实现多人同步开发

8、导入本地Git库的项目到eclipse

 CentOS安装Git实现多人同步开发

下一步

CentOS安装Git实现多人同步开发

下一步

CentOS安装Git实现多人同步开发

下一步

CentOS安装Git实现多人同步开发

点击Finish完后选中cms_repo点击Next

CentOS安装Git实现多人同步开发

下一步

CentOS安装Git实现多人同步开发

点击Finish完成,如下图项目已经成功导入到eclipse中。

CentOS安装Git实现多人同步开发

添加了新的文件需要提交,右键-->Team--Synchronize Workspace进行同步,类似svn的同步。

CentOS安装Git实现多人同步开发

填写用户名密码

CentOS安装Git实现多人同步开发

下一步

CentOS安装Git实现多人同步开发

双击IssueController.java查看变化的内容

CentOS安装Git实现多人同步开发

因为添加了新文件索引要为新文件添加索引选中项目右键-->Add to Index

CentOS安装Git实现多人同步开发

看看图标都变了

CentOS安装Git实现多人同步开发

提交项目

CentOS安装Git实现多人同步开发

下一步Git Staging(Git工作台)

CentOS安装Git实现多人同步开发

下一步

CentOS安装Git实现多人同步开发

点击OK将本地Git库代码推送到服务器如下图是提交后的项目:

 CentOS安装Git实现多人同步开发

yingyue的eclipse导入cms项目完成;

-----------------------------------------------------------------------------------------------------------------------------------------------

下面xiaofei开始导入项目到eclipse(xiaofei使用的是Windows XP系统)

 注意:因为xiaofei是普通的开发人员而yingyue既是开发人员又是Linux系统管理员,所以xiaofei只需要将公钥给系统管理员然后系统管理员将xiaofei的公钥放到/home/xiaofei/.ssh/authorized_keys即可

xiaofei选择Clone URI从服务器上直接导入如下图:

CentOS安装Git实现多人同步开发

点击Next填写链接信息protocol选择ssh协议端口默认22

CentOS安装Git实现多人同步开发

 点击Next

CentOS安装Git实现多人同步开发

选择master分支后点击Next

CentOS安装Git实现多人同步开发

点击Finish引入项目到eclipse

CentOS安装Git实现多人同步开发

CentOS安装Git实现多人同步开发

xiaofei添加了新代码并提交

CentOS安装Git实现多人同步开发

点击OK

CentOS安装Git实现多人同步开发

点击OK后xiaofei完成了提交

CentOS安装Git实现多人同步开发

这时yingyue就可以看到xiaofei提交的代码了

CentOS安装Git实现多人同步开发

完成

————————————————————————————————————————————————————————————

 

提示:如果报这个错

error: insufficient permission for adding an object to repository database ./objects

说明远程服务器的目录权限还不够

终极必杀技是使用

chmod 777 -R 库地址

更改,例如:

chmod 777 -R ../cms_repo.git/

另外还要注意每个人的Git版本要一致, eclipse的egit插件也要一致,否则会报奇奇怪怪的错。

 ————————————————————————————————————————————————————————————

 

最最后一步禁用shell登录:

出于安全考虑,创建的git用户不允许登录shell,这可以通过编辑/etc/passwd文件完成。找到类似下面的一行:

git:x:1001:1001:,,,:/home/禁止shell登录的用户名:/bin/bash

改为
git:x:1001:1001:,,,:/home/禁止shell登录的用户名:/usr/bin/git-shell

如下, 设置xiaofei不可登录远程主机

 vi /etc/passwd

CentOS安装Git实现多人同步开发

:wq保存并退出,当xiaofei在登录时 What do you think I am? A shell?

CentOS安装Git实现多人同步开发

这样,git用户可以正常通过ssh使用git,但无法登录shell,因为我们为git用户指定的git-shell每次一登录就自动退出。不是更安全吗?

 

 

————————————————————————————————————————————————————————————

2016年11月18日 12:32:25 补充

当xiaofei修改了代码push到服务器上后,yingyue更新代码后也修改了代码这时yingyue提交,发现push失败,提示objects目录下有文件没有写入权限。

情况与下面的这段场景相似:

最近给公司部署了 git 服务器(CentOS 6.3),由于之前没有配置 git server 的经验,搞了半天才把配置搞定。这里就不讲配置的问题了。创建了账户、项目并设置 git 权限后,使用 a 账号开始测试。一切正常,没有问题。

第二天上班,给同事建了个账号 b(a,b 账号同在 git 用户组),出现问题了,pull 正常, push 失败,提示 objects 目录下有文件没有写入权限。

果断 ssh 上服务器,把账号 a 和 b 都放到 git 用户组。继续测试,还是报错。没办法,只好一路 cd 到 objects 下,ll,发现有些文件没有对同组用户开启 w 权限。想了想,用“linux 创建文件默认权限”作为关键词 Google 了一下,看了几篇文章,了解了 umask 命令。

 

解决办法:

设置umask

/etc/profile和/etc/bashrc都可以用于设置用户登录系统时自动执行某些操作,他们的区别是/etc/profile只在用户第一次登录时被执行,而/etc/bashrc则在用户每次登录加载Bash Shell时都会被执行。

因而,如果是修改/etc/profile文件,将只对新创建的用户生效;而如果是修改/etc/bashrc文件,则对所有用户都生效。

 

如下:

[root@localhost cms_repo.git]# vi /etc/bashrc

 CentOS安装Git实现多人同步开发

改后

CentOS安装Git实现多人同步开发

 OK;