ubuntu 14.04搭建git服务器

想在单位内部署git服务器,因此,特别记录部署相关的安装步骤

1.  安装

root@ros-OptiPlex-3050:~# sudo apt-get install git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch
  git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git
0 upgraded, 1 newly installed, 0 to remove and 179 not upgraded.
Need to get 3,176 kB of archives.
After this operation, 24.1 MB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.6 [3,176 kB]
Fetched 3,176 kB in 7s (399 kB/s)                                                              
Selecting previously unselected package git.
(Reading database ... 258511 files and directories currently installed.)
Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.6_amd64.deb ...
Unpacking git (1:2.7.4-0ubuntu1.6) ...
Setting up git (1:2.7.4-0ubuntu1.6) ...
2. 添加用户

root@ros-OptiPlex-3050:~# sudo adduser git
Adding user `git' ...
Adding new group `git' (1003) ...
Adding new user `git' (1003) with group `git' ...
The home directory `/home/git' already exists.  Not copying from `/etc/skel'.
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for git
Enter the new value, or press ENTER for the default
    Full Name []:
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n]
root@ros-OptiPlex-3050:~# ll /home/git/
total 32
drwxr-xr-x 2 git  git  4096 7月  12 09:33 ./
drwxr-xr-x 6 root root 4096 7月  12 09:33 ../
-rw-r--r-- 1 git  git   220 7月  12 09:33 .bash_logout
-rw-r--r-- 1 git  git  3771 7月  12 09:33 .bashrc
-rw-r--r-- 1 git  git  8980 7月  12 09:33 examples.desktop
-rw-r--r-- 1 git  git   655 7月  12 09:33 .profile
3. 在/home/git目录下放置证书

4. 初始化git库

root@ros-OptiPlex-3050:/home/git#  git init --bare sample.git
Initialized empty Git repository in /home/git/sample.git/
root@ros-OptiPlex-3050:/home/git# ls
examples.desktop  sample.git

5. 禁用shell
root@ros-OptiPlex-3050:/home/git# sudo chown -R git:git sample.git
root@ros-OptiPlex-3050:/home/git# git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
-bash: git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell: No such file or directory
6.其他

  • 要方便管理公钥,用Gitosis

  • 要像SVN那样变态地控制权限,用Gitolite

posted @ 2019-07-12 09:56  李悠然  阅读(423)  评论(0编辑  收藏  举报