首页 > 系统相关 >Linux服务器上安装git(运维向)

Linux服务器上安装git(运维向)

时间:2024-10-16 20:32:17浏览次数:1  
标签:git centos 17 root 服务器上安装 VM my 运维向

(1).参考文献

官网在线教程:https://git-scm.com/book/zh/v2

官方网站:https://git-scm.com/

(2).实验环境

2核2G CentOS7.6.1810

(3).安装git

  1)yum或dnf安装

[root@VM-0-17-centos ~]# dnf -y install git-all

  2)源码安装

  安装依赖包

[root@VM-0-17-centos ~]# dnf -y install dh-autoreconf curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel
#为了添加文档的多种格式(doc、html、info),需要以下附加依赖
[root@VM-0-17-centos ~]# dnf -y install asciidoc xmlto docbook2X

  编译安装

[root@VM-0-17-centos ~]# tar xvf git-2.9.5.tar.xz
[root@VM-0-17-centos ~]# cd git-2.9.5/
[root@VM-0-17-centos git-2.9.5]# make configure
GIT_VERSION = 2.9.5
    GEN configure
[root@VM-0-17-centos git-2.9.5]# ./configure --prefix=/usr
[root@VM-0-17-centos git-2.9.5]# echo $?    #检查上一个命令是否有异常
0
[root@VM-0-17-centos git-2.9.5]# make all doc info
make[1]: Leaving directory `/root/git-2.9.5/Documentation'
make -C Documentation info
make[1]: Entering directory `/root/git-2.9.5/Documentation'
GEN doc.dep
make[2]: Entering directory `/root/git-2.9.5'
make[2]: `GIT-VERSION-FILE' is up to date.
make[2]: Leaving directory `/root/git-2.9.5'
make[1]: Leaving directory `/root/git-2.9.5/Documentation'
make[1]: Entering directory `/root/git-2.9.5/Documentation'
make[2]: Entering directory `/root/git-2.9.5'
make[2]: `GIT-VERSION-FILE' is up to date.
make[2]: Leaving directory `/root/git-2.9.5'
DB2TEXI user-manual.texi
/bin/sh: line 1: docbook2x-texi: command not found
make[1]: *** [user-manual.texi] Error 127
make[1]: Leaving directory `/root/git-2.9.5/Documentation'
make: *** [info] Error 2

  此时可以看到会报错"docbook2x-texi: command not found",我查了一圈发现,实际上已经安装(docbook2X),这里只需要设置一个软链接。

[root@VM-0-17-centos git-2.9.5]# ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi

  之后,重新执行"make all doc info",并继续安装

[root@VM-0-17-centos git-2.9.5]# make all doc info
[root@VM-0-17-centos git-2.9.5]# echo $?
0
[root@VM-0-17-centos git-2.9.5]# make install install-doc install-html install-info
[root@VM-0-17-centos git-2.9.5]# echo $?
0

  以上就安装好了。

(4).配置服务器仓库

  我个人认为一般会存在两种情况:1、先开发后搭建git服务器(这个情况我估计应该少很多了);2、先搭建git服务器后开发

  其他的先不说,先在服务器上新建一个git专属用户,专门管理git。

[root@VM-0-17-centos ~]# groupadd git
[root@VM-0-17-centos ~]# useradd git -g git
[root@VM-0-17-centos ~]# passwd git
Changing password for user git.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

  a.第一种情况模拟,我在个人的window系统上创建一个my_project目录,并在其中新增test1.txt、test2.sql。

    目录空白位置右键,点击”Open Git Bash Here“,打开命令行工具。然后执行如下命令:

$ git init  #初始化仓库
Initialized empty Git repository in C:/Users/admin/Desktop/my_project/.git/

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project (master)
$ ll -a
total 14
drwxr-xr-x 1 admin 197121  0 Sep 28 22:23 ./
drwxr-xr-x 1 admin 197121  0 Sep 28 22:10 ../
drwxr-xr-x 1 admin 197121  0 Sep 28 22:23 .git/  #初始化成功
-rw-r--r-- 1 admin 197121 13 Sep 28 22:20 test1.txt
-rw-r--r-- 1 admin 197121 13 Sep 28 22:20 test2.sql

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project (master)
$ git status    #查看状态
On branch master

No commits yet

Untracked files:    #未跟踪的文件
  (use "git add <file>..." to include in what will be committed)
        test1.txt
        test2.sql

nothing added to commit but untracked files present (use "git add" to track)

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project (master)
$ git add .  #将当前目录下所有文件进行跟踪,也可以跟随文件名进行单点添加

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project (master)
$ git status
On branch master

No commits yet

Changes to be committed:    #要提交的更改
  (use "git rm --cached <file>..." to unstage)
        new file:   test1.txt
        new file:   test2.sql


admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project (master)
$ git commit -m 'initial project version'  #提交并备注
[master (root-commit) 59a2071] initial project version
 2 files changed, 2 insertions(+)
 create mode 100644 test1.txt
 create mode 100644 test2.sql

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project (master)
$ cd ..  #返回上一层

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop
$ git clone --bare my_project my_project.git  #克隆一个裸仓
Cloning into bare repository 'my_project.git'...
done.

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop
$ scp -r my_project.git git@[服务器地址]:/home/git/my_project.git  #将裸仓上传至服务器端
The authenticity of host ' [服务器地址]([服务器地址])' can't be established.
ED25519 key fingerprint is SHA256:ZIPLdZAeqo7YVJ3qpwbt+Rw+ymtMWdOq1d1lR3gZ9Uk.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[服务器地址]' (ED25519) to the list of known hosts.
git@[服务器地址]'s password:
config 100% 164 9.1KB/s 00:00
description 100% 73 4.1KB/s 00:00
HEAD 100% 23 1.3KB/s 00:00
applypatch-msg.sample 100% 478 26.8KB/s 00:00
commit-msg.sample 100% 896 51.0KB/s 00:00
fsmonitor-watchman.sample 100% 4726 243.7KB/s 00:00
post-update.sample 100% 189 11.1KB/s 00:00
pre-applypatch.sample 100% 424 24.4KB/s 00:00
pre-commit.sample 100% 1649 93.1KB/s 00:00
pre-merge-commit.sample 100% 416 24.2KB/s 00:00
pre-push.sample 100% 1374 79.1KB/s 00:00
pre-rebase.sample 100% 4898 263.4KB/s 00:00
pre-receive.sample 100% 544 31.2KB/s 00:00
prepare-commit-msg.sample 100% 1492 84.5KB/s 00:00
push-to-checkout.sample 100% 2783 158.6KB/s 00:00
sendemail-validate.sample 100% 2308 125.5KB/s 00:00
update.sample 100% 3650 192.5KB/s 00:00
exclude 100% 240 13.6KB/s 00:00
9f7cb32c94b4023186abd39e4b26f7988079f2 100% 29 1.7KB/s 00:00
a207135e033a0df9364b34c256403ca36acf96 100% 132 7.7KB/s 00:00
7e2bcac3de881816c992429389a8b2b4d8e3b9 100% 63 3.6KB/s 00:00
packed-refs 100% 105 6.0KB/s 00:00

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop

    到服务器上看下,裸仓是否存在。

[root@VM-0-17-centos ~]# su git
[git@VM-0-17-centos root]$ cd
[git@VM-0-17-centos ~]$ ll
total 4
drwxr-xr-x 6 git git 4096 Sep 28 22:48 my_project.git
[git@VM-0-17-centos ~]$ ls my_project.git/
config  description  HEAD  hooks  info  objects  packed-refs  refs

    这就完成了,下面我们做一下测试。将my_project目录下的文件删除,接着从服务器上将文件clone下来。(还是接着上面的window命令行,我们当前的地址是在~/Desktop/目录下)

$ git clone git@[服务器地址]:my_project.git
Cloning into 'my_project'...
git@[服务器地址]'s password:
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop
$ cd my_project/

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project (master)
$ ls -a
./ ../ .git/ test1.txt test2.sql

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project (master)

    测试完美通过。

  b.第二种情况模拟,这种情况才是大多数情况,并且由于工具的普及,直接敲代码的情况可能已经较少了。

    直接在服务器上创建裸仓。

[git@VM-0-17-centos ~]$ pwd
/home/git
[git@VM-0-17-centos ~]$ git init --bare my_project2.git
Initialized empty Git repository in /home/git/my_project2.git/
[git@VM-0-17-centos ~]$ ls
my_project2.git  my_project.git
[git@VM-0-17-centos ~]$ ls my_project2.git/
branches  config  description  HEAD  hooks  info  objects  refs

    本地直接clone,之后进行开发

$ git clone git@[服务器地址]:my_project2.git
Cloning into 'my_project2'...
git@[服务器地址]'s password:
warning: You appear to have cloned an empty repository.

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop
$ cd my_project2/

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project2 (master)
$ ll -a
total 12
drwxr-xr-x 1 admin 197121 0 Sep 29 21:56 ./
drwxr-xr-x 1 admin 197121 0 Sep 29 21:56 ../
drwxr-xr-x 1 admin 197121 0 Sep 29 21:56 .git/

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project2 (master)

(5).传输协议的相关配置

  Git可以使用四种不同的协议来传输资料:本地协议(Local),HTTP 协议,SSH(Secure Shell)协议及 Git 协议。 它们各有优缺点,但据我所知多数情况下采用SSH协议或HTTP协议。优缺点详见官方文档:https://git-scm.com/book/zh/v2/%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e7%9a%84-Git-%e5%8d%8f%e8%ae%ae

  1)SSH协议上面已经用到了,但是实际情况下,并不会将服务器密码告知开发人员,此时就需要SSH公私钥对。

    首先,你需要确认个人是否已经拥有密钥。 默认情况下,用户的 SSH 密钥存储在其 ~/.ssh 目录下。 进入该目录并列出其中内容,你便可以快速确认自己是否已拥有密钥:

$ cd ~/.ssh/

admin@DESKTOP-4CERLUK MINGW64 ~/.ssh
$ ls -a
./  ../  id_ed25519  id_ed25519.pub  known_hosts  known_hosts.old

    其中id_ed25529和id_ed25519.pub就是一对公私钥对,.pub文件为本地的公钥,对应的另一个为私钥。 如果找不到这样的文件(或者根本没有 .ssh 目录),你可以通过运行 ssh-keygen 程序来创建它们。 在 Linux/macOS 系统中,ssh-keygen 随 SSH 软件包提供;在 Windows 上,该程序包含于 MSysGit 软件包中。我这里使用的是Windows系统,git的命令行:

$ ssh-keygen.exe -o
Generating public/private ed25519 key pair.
Enter file in which to save the key (/c/Users/admin/.ssh/id_ed25519):
Enter passphrase for "/c/Users/admin/.ssh/id_ed25519" (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/admin/.ssh/id_ed25519
Your public key has been saved in /c/Users/admin/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:cUJipY/OfsEfq25aCOh+34O1KT79Ya/3KG4eTe883SQ admin@DESKTOP-4CERLUK
The key's randomart image is:
+--[ED25519 256]--+
|      o.o        |
|     . +         |
|      . o .      |
|   .   o +       |
|  . . ..S   .    |
| .   + .+ .o .E .|
|  .   ++.=+o. .+.|
| .  ..+oB.=+.+. o|
|  .. o=B+B=+o.+. |
+----[SHA256]-----+
admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project2 (master)

    ssh-keygen 会确认密钥的存储位置(默认是 .ssh/id_rsa),然后它会要求你输入两次密钥口令。 如果你不想在使用密钥时输入口令,将其留空即可。 然而,如果你使用了密码,那么请确保添加了 -o 选项,它会以比默认格式更能抗暴力破解的格式保存私钥。 你也可以用 ssh-agent 工具来避免每次都要输入密码。

    接着将公钥配置到服务器上。注意:我们在原本的公钥前面添加 no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty 用来限制ssh端口转发访问服务器。

[git@VM-0-17-centos ~]$ mkdir .ssh
[git@VM-0-17-centos ~]$ chmod 700 .ssh
[git@VM-0-17-centos ~]$ touch .ssh/authorized_keys
[git@VM-0-17-centos ~]$ chmod 600 .ssh/authorized_keys
[git@VM-0-17-centos ~]$ vim .ssh/authorized_keys
no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty [公钥内容]

    进行测试,将my_project目录删除,重新clone:

$ git clone git@[服务器地址]:my_project
Cloning into 'my_project'...
remote: Counting objects: 3, done.  #可以看到直接开始clone,不需要输入密码了
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop

    注意:目前测试是通过了,但是也造成了开发人员可以免密登录服务器,所以还需要进行进一步的设置。

    借助一个名为 git-shell 的受限 shell 工具,你可以方便地将用户 git 的活动限制在与 Git 相关的范围内。 该工具随 Git 软件包一同提供。如果将 git-shell 设置为用户 git 的登录 shell(login shell), 那么该用户便不能获得此服务器的普通 shell 访问权限。 若要使用 git-shell,需要用它替换掉 bash 或 csh,使其成为该用户的登录 shell。为进行上述操作,首先你必须确保 git-shell 的完整路径名已存在于 /etc/shells 文件中。

[root@VM-0-17-centos ~]# cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/bin/tcsh
/bin/csh
[root@VM-0-17-centos ~]# which git-shell
/usr/bin/git-shell

    确认没有问题后才可以使用 chsh <username> -s <shell> 命令修改系统用户的 默认登录shell。或者直接vim /etc/passwd,将git用户登录模式改为/usr/bin/git-shell。

[root@VM-0-17-centos ~]# chsh git -s $(which git-shell)    #我这里与chsh git -s /usr/bin/git-shell等价
Changing shell for git.
chsh: Warning: "/usr/bin/git-shell" is not listed in /etc/shells.
Shell changed.

    最后测试一下是否被限制。在windows系统上使用git的命令行尝试。

$ ssh git@[服务器地址]
Last login: Mon Sep 30 19:16:21 2024 from 223.64.99.42
fatal: Interactive git shell is not enabled.
hint: ~/git-shell-commands should exist and have read and execute access.
Connection to [服务器地址] closed.

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop

  2)HTTP协议

    我们一般通过SSH进行授权访问,通过git://进行无授权访问,但HTTP协议可以同时实现以上两种方式的访问。而配置一个轻量级http服务器一般只需要在服务器上启动Git自带的名为git-http-backend的CGI脚本。该 CGI 脚本将会读取由 git fetch 或 git push 命令向 HTTP URL 发送的请求路径和头部信息, 来判断该客户端是否支持 HTTP 通信(不低于 1.6.6 版本的客户端支持此特性)。如果 CGI 发现该客户端支持智能(Smart)模式,它将会以智能模式与它进行通信, 否则它将会回落到哑(Dumb)模式下(因此它可以对某些老的客户端实现向下兼容)。

    这里采用Apache来作为CGI服务器,如果没有Apache可以执行如下命令:

[root@VM-0-17-centos ~]# dnf -y install httpd httpd-tools
[root@VM-0-17-centos ~]# httpd -M | grep -E 'cgi|alias|env'  #查看Apache启用模块
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
 alias_module (shared)
 env_module (shared)
 setenvif_module (shared)
 vhost_alias_module (shared)
 proxy_fcgi_module (shared)
 proxy_scgi_module (shared)
 cgi_module (shared)
#如果缺少以上任意一种可以使用以下命令安装
[root@VM-0-17-centos ~]# dnf -y install cgi_module alias_module env_module

    该操作将会启用 cgi_module, alias_module 和 env_module 等 Apache 模块, 这些模块都是使该功能正常工作所必须的。

    还要将裸仓的上级目录(例如上文中的/home/git)的用户组设置为apache(注意:这里是apache的用户组,不同系统可能不一样),这样 Web 服务器才能读写该仓库, 因为运行 CGI 脚本的 Apache 实例默认会以该用户的权限运行。因为这里不用ssh认证,所以我将裸仓的上级目录改到/srv/git,操作如下:

[root@VM-0-17-centos ~]# mkdir -p /srv/git

    接着修改Apache的配置文件,我这里直接新增一个配置文件到/etc/httpd/conf.d/目录下,因为/etc/httpd/conf/httpd.conf中存在"IncludeOptional conf.d/*.conf"(IncludeOptional引用的路径有问题时会被忽略,不会报错)引用了/etc/httpd/conf.d/目录下所有.conf文件。命令如下:

[root@VM-0-17-centos ~]# vim /etc/httpd/conf.d/git.conf
# 监听8989端口
Listen 8989
<VirtualHost *:8989>
    # git库的存放目录
    SetEnv GIT_PROJECT_ROOT /srv/git
    #如果没有下面这一行,那么无授权客户端只能访问带 git-daemon-export-ok 文件的版本库;如果有Git将会公开服务器上所有的仓库
    SetEnv GIT_HTTP_EXPORT_ALL
    # 将以/git/开头的请求映射到git-http-backend这个CGI脚本
    ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
    #匹配目录
    <Directory "/usr/libexec/git-core">
        # 匹配文件名
        <Files "git-http-backend">
            # 用户认证类型
            AuthType Basic
            # 设置授权领域的名称
            AuthName "Git Access"
            # 设置用于身份验证的用户的账号密码地址
            AuthUserFile /srv/git/.htpasswd
            Require expr !(%{QUERY_STRING} -strmatch '*service=git-receive-pack*' || %{REQUEST_URI} =~ m#/git-receive-pack$#)
            # 强制用户必须身份验证才能访问受保护的资源
            Require valid-user
        </Files>
    </Directory>
    <Directory "/srv/git">
        #启用 CGI 脚本的执行权限
        Options +ExecCGI
        #忽略.htaccess 文件
        AllowOverride None
        #授权所有用户访问当前目录下的所有文件
        Require all granted
    </Directory>
</VirtualHost>
[root@VM-0-17-centos ~]# systemctl restart httpd

    注意:不同系统git-http-backend的CGI脚本路径可能不一样,根据实际情况修改。CentOS是/usr/libexec/git-core/git-http-backend,有些liinux系统是/usr/lib/git-core/git-http-backend。

    Require expr !(%{QUERY_STRING} -strmatch '*service=git-receive-pack*' || %{REQUEST_URI} =~ m#/git-receive-pack$#) 配置说明:

      %{QUERY_STRING} 这是HTTP请求的查询字符串部分,即URL中问号后面的参数部分;

      %{QUERY_STRING} -strmatch '*service=git-receive-pack*' 这部分表示查询字符串中是否包含`service=git-receive-pack`。`-strmatch`表示字符串匹配,`*service=git-receive-pack*`表示允许前后有任意字符的匹配条件;

      || 这是逻辑或操作符,表示两个条件中的任意一个满足即可;

      %{REQUEST_URI} =~ m#/git-receive-pack$# 这部分检查请求的URI(路径部分)是否以`/git-receive-pack`结尾。`=~`表示正则表达式匹配,`m#...#`是正则表达式的模式,而`$`表示匹配字符串的末尾。

      因此,整个 Require 表达式的含义是:仅当查询字符串包含`service=git-receive-pack`或URI以`/git-receive-pack`结尾时,这部分规则才会被触发。(即在上传时需要进行身份验证)

    更多Apache授权访问配置请查看官网文档:https://httpd.apache.org/docs/current/howto/auth.html

    创建一个授权账号,如下:

[root@VM-0-17-centos ~]# htpasswd -c /srv/git/.htpasswd testuser
New password: 
Re-type new password: 
Adding password for user testuser
[root@VM-0-17-centos ~]# chgrp apache /srv/git/.htpasswd

    创建仓库便于进行测试:

[root@VM-0-17-centos conf]# cd /srv/git/
[root@VM-0-17-centos git]# git init --bare my_project3.git  #创建裸仓
Initialized empty Git repository in /srv/git/my_project3.git/
[root@VM-0-17-centos git]# git init --bare my_project4.git  #创建无授权客户可以访问的裸仓
Initialized empty Git repository in /srv/git/my_project4.git/
[root@VM-0-17-centos git]# touch my_project4.git/git-daemon-export-ok
#也可以chown -R apache:apache /srv/git将个人与组都改为apache
[root@VM-0-17-centos git]# chgrp -R apache /srv/git
[root@VM-0-17-centos git]# chmod -R g+w /srv/git/
[root@VM-0-17-centos git]# ll
total 4
drwxrwxr-x 7 root apache 4096 Oct 12 16:06 my_project3.git
drwxrwxr-x 7 root apache 4096 Oct 14 18:30 my_project4.git

    将服务器端 /etc/httpd/conf.d/git.conf 配置文件中的 "SetEnv GIT_HTTP_EXPORT_ALL"删除或注释,之后进行clone测试(Windows客户端):

$ git clone http://[服务器地址]:8989/git/my_project3.git
Cloning into 'my_project3'...
fatal: repository 'http://[服务器地址]:8989/git/my_project3.git/' not found

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop
$ git clone http://[服务器地址]:8989/git/my_project4.git
Cloning into 'my_project4'...
warning: You appear to have cloned an empty repository.

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop

    可以看到my_project3无法找到,但my_project4正常clone,接着将配置还原,再试一次:

$ rm -rf my_project4/

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop
$ rm -rf my_project3/

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop
$ git clone http://[服务器地址]:8989/git/my_project3.git
Cloning into 'my_project3'...
warning: You appear to have cloned an empty repository.

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop
$ git clone http://[服务器地址]:8989/git/my_project4.git
Cloning into 'my_project4'...
warning: You appear to have cloned an empty repository.

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop

    再进行push测试,git push时会从弹出输入账号密码的界面,如下图:

$ echo "my_project3" > my_project3/file.txt

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project3 (master)
$ cd my_project3/

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project3 (master)
$ git add .
warning: in the working copy of 'file.txt', LF will be replaced by CRLF the next time Git touches it

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project3 (master)
$ git commit -m "Initial commit"
[master (root-commit) f1c23cd] Initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 file.txt

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project3 (master)
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 219 bytes | 219.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To http://[服务器地址]:8989/git/my_project3.git
 * [new branch]      master -> master

admin@DESKTOP-4CERLUK MINGW64 ~/Desktop/my_project3 (master)

  这样就完成了。

 

  

 

    

参考资料:https://www.cnblogs.com/Kyle023/p/14746741.html

     https://blog.csdn.net/GTOFEI013/article/details/89519104

     https://blog.csdn.net/weixin_30570101/article/details/95021329

标签:git,centos,17,root,服务器上安装,VM,my,运维向
From: https://www.cnblogs.com/diantong/p/18437995

相关文章

  • SciTech-AV-Audio-DAP(Digital Audio Processing)-Perceived Loudness(感知响度)-EBU
    PerceivedLoudness(EBUR128)ThespecificationEBUR128/ITU-RBs.1770-4describesanalgorithmforcalculationoftheperceivedloudnessofrealworldaudiosignals,forexamplenopuresinetones.FordetailsoftherecommendationspleaseseeEBUR......
  • git 修改之前提交记录的某几次记录的账号和邮箱
    修改Git提交记录的作者名和邮箱最近在使用Git时,遇到了一个需求:修改某些提交记录中的提交名和邮箱。由于提交时误用了错误的姓名和邮箱,历史记录中的几次提交需要更新。发现使用gitrebase结合gitcommit--amend是一种比较优雅的方式,可以灵活修改历史记录中的提交名和邮箱......
  • 24K star!告别199韭菜课,来GitHub免费学大模型
    现在的网上充斥着各种AI课程,比如李一舟的199课程。今天推荐一个开源项目,它帮你整理好了大模型学习的roadmap,有资料有代码还免费,它就是:llm-course。llm-course是什么?本项目的内容是一个针对大语言模型的课程,在之前的热点汇总中和大家提过,当时项目内容没有完整,缺了LLM工程......
  • git-pull request
    一、git凭据在使用Git进行版本控制时,凭据主要用于身份验证,以确保用户能够安全地访问和操作代码仓库常见的Git凭据类型:1.用户名和密码最基本的身份验证方式。用户在克隆、推送或拉取时输入其用户名和密码。优点:简单,无需额外配置。缺点:安全性较低,因为密码可以被......
  • 从Windows 11 23H2升级至24H2后,Git操作提示文件所有权错误的3种有效解决方案
    从Windows1123H2升级至24H2后,Git操作提示文件所有权错误的3种有效解决方案在升级至Windows1124H2后,使用gitadd等命令时,可能会遇到如下错误提示:Error:libgit2returned:repositorypath'D:/repo/it-tools'isnotownedbycurrentuser.Toaddanexceptionforth......
  • Git常用经验
    Git显示单次commit的改动内容gitshowcommit-idgitshowHEAD~什么都不带的时候默认显示最近的一次gitshowpatch相关生成patchgitformat-patchHEAD^应用patch,保留commit信息gitamfile打patch,但是不保留commit信息gitapplyfilegitlog特定搜索搜索特定的......
  • 极狐GitLab 发布安全补丁版本 17.4.2, 17.3.5, 17.2.9
    本分分享极狐GitLab补丁版本17.4.2,17.3.5,17.2.9的详细内容。今天,极狐GitLab专业技术团队正式发布了17.4.2,17.3.5,17.2.9版本。这几个版本包含重要的缺陷和安全修复代码,我们强烈建议所有私有化部署用户应该立即升级到上述的某一个版本。对于极狐GitLabSaaS,技术团队......
  • Docker Compose部署GitLab
    今天我将向你展示如何在一小时内安装GitLab服务器,并在其中运行第一个CI/CD进程。本文是“如何开始使用流行的CI/CD工具”系列文章的一部分。在本文中,我将向你展示如何安装CI/CD工具,以及如何准备基于Maven构建和测试一个简单项目的流程。什么是GitLab?Gitlab是一款......
  • 强大的无头UI表格库:TanStack Table!Github Star达到了惊人的25K!
    强大的无头UI表格库:TanStackTable!GithubStar达到了惊人的25K!在构建现代化Web应用时,表格和数据网格是常见的UI组件,特别是在处理大量数据或需要复杂交互时,选择合适的表格库尤为重要。TanStackTable是一款功能强大的HeadlessUI表格库,支持TypeScript/JavaScript、React、......
  • Git提交内容规范
    Git提交内容规范前缀解释示例feat新功能feat:新增租⻋控制fix修复fix:新增租⻋控制docs⽂档变更docs:租⻋控制style代码格式style:⼩程序⾸⻚央视refactor重构refactor:租⻋控制perf性能优化perf:数据导出test增加测试test:增......