當前位置:首頁 » 操作系統 » linux的git安裝

linux的git安裝

發布時間: 2022-11-30 06:19:35

linux操作系統下安裝Git(yum 方法)

使用yum安裝確實簡單方便,但 yum 存在一個問題就是安裝的版本不好控制。
以下安裝的版本為1.8.3.1,這個版本太老了。
截至發布文章的時候最新版本為:v2.30.0
Git 最新版本: https://github.com/git/git/releases
源碼編譯安裝看這里 https://www.jianshu.com/p/d06538116a2e

直接使用以下命令

安裝完成之後使用以下命令查看安裝的 Git 的版本,驗證是否安裝成功

出現以下信息則安裝成功

此方法安裝 Git 的默認路徑為(/usr/libexec/git-core)可以使用命令查看安裝目錄信息

安裝目錄信息如下圖所示

② 如何讓 linux安裝 git

一、使用包管理器安裝Git
Git已經被所有的主流Linux發行版所支持。所以安裝它最簡單的方法就是使用各個Linux發行版的包管理器。
1、Debian, Ubuntu, 或 Linux Mint

1

$ sudo apt-get install git

2、Fedora, CentOS 或 RHEL

1

$ sudo yum install git或$ sudo dnf install git

3、Arch Linux

1

$ sudo pacman -S git

4、OpenSUSE

1

$ sudo zypper install git

5、Gentoo

1

$ emerge --ask --verbose dev-vcs/git

二、從源碼安裝Git
如果由於某些原因,希望從源碼安裝Git,按照如下介紹操作。

1、安裝依賴包
在構建Git之前,先安裝它的依賴包。

1
2
3
4

//Debian, Ubuntu 或 Linux Mint
$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto docbook2x
//Fedora, CentOS 或 RHEL
$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2x

2、從github官網下載最新版本的Git。然後在/usr下構建和安裝。
注意,如果打算安裝到其他目錄下(例如:/opt),那就把「--prefix=/usr」這個配置命令使用其他路徑替換掉。

1
2
3
4
5

$ cd git-x.x.x
$ make configure
$ 。/configure --prefix=/usr
$ make all doc info
$ sudo make install install-doc install-html install-info

③ Linux系統中怎麼安裝Git

1、yum方式安裝 # yum -y install git 如果提示系統提示沒有找到git包,可以採用下面的方式 2、下載Git源碼包 官網:http://git-scm.com/ $ tar -xjvf git-1.7.4.1.tar.bz2 $ cd git-1.7.4.1/ $ make prefix=/usr/local all $ make prefix=/usr/...

④ Linux系統上怎樣安裝Git

  • 用git --version命令檢查是否已經安裝

⑤ 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 [email protected]:/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/.
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 伺服器時不會再提示上面的語句。

⑥ linux搭建git遠程倉庫

1. linux和windows端分別安裝git,其中linux中可以用yum安裝

[root@node0~]#yum install git

git的默認安裝路徑在/usr/libexec/git-core

[root@node0 git-core]#cd /usr/libexec/git-core

[root@node0 git-core]#git --version

git version 1.7.1

2.設置linux端git的用戶名和密碼

[root@node0 git-core]# groupadd git

[root@node0 git-core]# useradd wang -g git

[root@node0 git-core]# passwd wang

New password:

3.在伺服器端創建遠程倉庫

[root@node0 ~]# mkdir -p /mnt/gitrep/wjf

[root@node0 ~]# cd /mnt/gitrep/wjf/

[root@node0 wjf]# git init

Initialized empty Git repository in /mnt/gitrep/wjf/.git/

把倉庫所屬用戶改為wang(git的用戶名)

[root@node0 wjf]# chown -R wang:git .git/

註:chown將指定文件的擁有者改為指定的用戶或組 -R處理指定目錄以及其子目錄下的所有文件

4.在windows客戶端克隆倉庫 

$ git clone [email protected]:/mnt/gitrep/wjf/.git

Cloning into 'wjf'...

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

RSA key fingerprint is SHA256:MgWCWF************************1m2tI.

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

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

[email protected]'s password:

第一次連接遠程倉庫,出現黑體部分,這是因為Git使用SSH連接,而SSH連接在第一次驗證GitHub伺服器的Key時,需要你確認GitHub的Key的指紋信息是否真的來自GitHub的伺服器,鍵入yes,然後輸入遠程倉庫的密碼就可以了。

5.實際中也通常通過設置公鑰的方式來連接遠程倉庫,這樣就不用每次連接都需要密碼了。

設置公鑰:

1.在windows客戶端的gitbash中生成用戶私鑰和公鑰

$ ssh-keygen -t rsa -C "[email protected]"

在c盤用戶路徑下的/.ssh文件夾下會生成私鑰id_rsa和公鑰id_rsa.pub

2.linux端

首先 Git伺服器打開RSA認證,即,修改/etc/ssh/sshd_config,將其中的以下三項打開

RSAAuthentication yes 

 PubkeyAuthentication yes 

 AuthorizedKeysFile .ssh/authorized_keys

然後,將客戶端生成的公鑰給到伺服器端

即,將公鑰給到 home/wang(git的用戶名)/.ssh/authorized_keys

[root@node0 ~]# cd /home/wang

[root@node0 wang]# mkdir .ssh

[root@node0 wang]# chmod 777 .ssh

[root@node0 wang]# touch .ssh/authorized_keys

在windows客戶端的gitbash中 執行:

$ ssh [email protected] 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

然後在linux端:

[root@node0 wang]# chmod 600 .ssh/authorized_keys

[root@node0 wang]# chmod 700 .ssh

[root@node0 wang]# chown wang:git .ssh

[root@node0 wang]# chown wang:git .ssh/authorized_keys 

至此,以後再連接遠程倉庫就不需要密碼了。

若仍需要密碼,可以查看ssh連接日誌/var/log/secure:

常見連接失敗原因:Authentication refused: bad ownership or modes for directory /home/wang/.ssh 

這時需要檢查該目錄的所屬用戶和讀寫許可權等級是否符合要求。公鑰以及.ssh文件的許可權應該屬於git的用戶和用戶組,讀寫許可權等級.ssh 700,authorized_keys 600.

熱點內容
shell腳本平方計算公式 發布:2024-04-26 23:29:26 瀏覽:186
比較實惠的雲伺服器 發布:2024-04-26 23:24:57 瀏覽:973
怎麼增加電腦緩存 發布:2024-04-26 23:23:46 瀏覽:450
android調試gdb 發布:2024-04-26 23:22:27 瀏覽:98
androidsocket服務 發布:2024-04-26 22:49:53 瀏覽:980
python編譯時加密 發布:2024-04-26 22:49:20 瀏覽:246
買車看哪些配置參數 發布:2024-04-26 22:45:50 瀏覽:835
linux顯示圖像 發布:2024-04-26 22:45:41 瀏覽:493
flash腳本格式 發布:2024-04-26 22:43:41 瀏覽:452
c語言求三位數 發布:2024-04-26 22:43:39 瀏覽:690