Ubuntu Server搭建Git服务器
1.配置
硬件:树莓派B4
硬盘:4T机械硬盘
系统:ubuntu-22.04.2-preinstalled-server-arm64+raspi(树莓派官网下载)
2.前期准备
根据树莓派官网设置烧录系统并运行起来。
3.挂载硬盘
参考:Ubuntu Server搭建SVN服务器_鱼听禅的博客-CSDN博客
4.安装Git
4.1 安装Git服务器
ubuntu@ubuntu:~$ sudo apt-get install git
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
git is already the newest version (1:2.34.1-1ubuntu1.8).
git set to manually installed.
The following packages were automatically installed and are no longer required:ibverbs-providers libboost-iostreams1.74.0 libboost-thread1.74.0 libcephfs2 libgfapi0libgfrpc0 libgfxdr0 libglusterfs0 libibverbs1 libldb2 librados2 librdmacm1 libtalloc2libtevent0 liburing2 libwbclient0 python3-dnspython python3-gpg python3-ldbpython3-markdown python3-pygments python3-requests-toolbelt python3-samba python3-tallocpython3-tdb samba-common samba-common-bin samba-dsdb-modules samba-libs samba-vfs-modulestdb-tools
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
4.2 查看git版本
ubuntu@ubuntu:~$ git --version
git version 2.34.1
4.3 创建git仓库
ubuntu@ubuntu:/mnt$ cd /DbDisk
-bash: cd: /DbDisk: No such file or directory
ubuntu@ubuntu:/mnt$ cd DbDisk
ubuntu@ubuntu:/mnt/DbDisk$ cd git
-bash: cd: git: No such file or directory
ubuntu@ubuntu:/mnt/DbDisk$ sudo mkdir git
ls
ubuntu@ubuntu:/mnt/DbDisk$ ls
'System Volume Information' git svn
ubuntu@ubuntu:/mnt/DbDisk$ cd git
4.4 创建版本库
ubuntu@ubuntu:/mnt/DbDisk/git$ sudo mkdir Test
ubuntu@ubuntu:/mnt/DbDisk/git$ ll
total 4
drwxrwxrwx 1 root root 144 Apr 12 14:35 ./
drwxrwxrwx 1 root root 4096 Apr 12 14:30 ../
drwxrwxrwx 1 root root 0 Apr 12 14:35 Test/
ubuntu@ubuntu:/mnt/DbDisk/git$ cd Test
ubuntu@ubuntu:/mnt/DbDisk/git/Test$ git init # 进入版本库后再初始化
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /mnt/DbDisk/git/Test/.git/
4.5本地直接使用ssh访问git库。
ssh://用户名@公网IP:端口(默认ssh端口时可省略)/mnt/DbDisk/git/Test/.git