當前位置:編程學習大全網 - 源碼下載 - linux如何搭建git

linux如何搭建git

1、環境準備

服務器:CentOS 7.3 + git (1.8.3.1)

客戶端:win10 + git (2.17.0.windows.1)

2、服務器安裝git

yum install -y git 

3、創建git用戶,管理 git服務

[root@localhost home]# useradd git

[root@localhost home]# passwd git

4、服務器創建git 倉庫

設置/home/git/repository-git 為git 服務器倉庫,然後把 git 倉庫的 owner 修改為 git 用戶。

復制代碼

[root@localhost git]# mkdir repository-git

[root@localhost git]# git init --bare repository-git/

Initialized empty Git repository in /home/git/repository-gt/

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

5、客戶端安裝git

下載 Git for Windows,地址:https://git-for-windows.github.io/

安裝完之後,可以使用 Git Bash 作為命令行客戶端。

5.1、選擇壹個目錄 F:\project\sell 作為本地倉庫,右鍵進入Git Bash 命令行模式

初始化本地倉庫:git init

5.2、嘗試克隆壹個服務器的空倉庫到本地倉庫

git clone git@192.168.116.129:/home/git/repository-gt

第壹次連接到目標 Git 服務器時會得到壹個提示:

The authenticity of host '192.168.116.129(192.168.116.129)' can't be established.

RSA key fingerprint is SHA256:Ve6WV/SCA059EqoUOzbFoZdfmMh3B259nigfmvdadqQ.

Are you sure you want to continue connecting (yes/no)?

選擇 yes:

Warning: Permanently added '192.168.116.129' (RSA) to the list of known hosts.

此時 C:\Users\用戶名\.ssh 下會多出壹個文件 known_hosts,以後在這臺電腦上再次連接目標 Git 服務器時不會再提示上面的語句。

  • 上一篇:小程序源代碼時代
  • 下一篇:兒童節海報怎麽畫?幼兒園六壹活動主題方案
  • copyright 2024編程學習大全網