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

git安裝linux

發布時間: 2022-09-07 09:42:24

『壹』 linux怎麼安裝git 命令

一、使用包管理器安裝GitGit已經被所有的主流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 ubuntu 上安裝git,id

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

『叄』 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
用git --version命令檢查是否已經安裝

2
在CentOS5的版本,由於yum源中沒有git,所以需要預先安裝一系列的依賴包。在CentOS6的yum源中已經有git的版本了,可以直接使用yum源進行安裝。

3
yum -y install git
但是yum源中安裝的git版本是1.7.1,Github等需要的Git版本最低都不能低於1.7.2 。所以我們一般不用上面的方法,而是下載git源碼編譯安裝。

END
編譯安裝git
1
首先更新系統
yum -y update
更新完成之後有6.5變成6.7了

2
安裝依賴的包
yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
3
下載git源碼並解壓
$ wget https://github.com/git/git/archive/v2.3.0.zip
$ unzip v2.3.0.zip
$ cd git-2.3.0

4
編譯安裝:
將其安裝在「/usr/local/git」目錄下。
make prefix=/usr/local/git all
make prefix=/usr/local/git install
因為伺服器時間不對編譯的過程中報錯如下圖,使用ntpdate自動校正系統時間。報錯「Writing perl.mak for Git make[2]: *** [perl.mak] Error 1」,請重啟apache服務,service httpd restart。

5
編譯完成之後使用git --version 查看git版本,居然還是1.7.1,這是因為它默認使用了"/usr/bin"下的git。
你可以用下面的命令查看git所在的路徑:
$ whereis git
git: /usr/bin/git /usr/local/git /usr/share/man/man1/git.1.gz

6
我們要把編譯安裝的git路徑放到環境變數里,讓它替換"/usr/bin"下的git。為此我們可以修改「/etc/profile」文件(或者/etc/bashrc文件)。
vim /etc/profile
然後在文件的最後一行,添加下面的內容,然後保存退出。
export PATH=/usr/local/git/bin:$PATH

7
不想重啟系統,使用source命令立即生效
source /etc/profile
8
然後再次使用git --version 查看git版本,發現輸出2.3.0,表明安裝成功。

『伍』 如何在線上環境linux安裝git

1.首先下載git源碼 自己度娘搜索下載即可。 2.xz文件解壓 12xz -d git-2014-08-20.tar.xztar -xvf git-2014-08-20.tar3.安裝git 12345cd git-2014-08-20/autoconf./configure --prefix=/usr/local/git/makemake install如果make的時候報錯:/bin/sh: msgfmt: command not found 則需要: yum install gettext-devel 4.將git加到環境變數中 1vim /etc/profile 12export GIT_HOME=/usr/local/git/export <a href="https:///s?wd=PATH&tn=44039180_cpr&fenlei=-w9Uz4Bmy-bIi4WUvYETgN-" target="_blank" class="-highlight">PATH</a>=$<a href="https:///s?wd=PATH&tn=44039180_cpr&fenlei=-w9Uz4Bmy-bIi4WUvYETgN-" target="_blank" class="-highlight">PATH</a>:$GIT_HOME/<a href="https:///s?wd=bin&tn=44039180_cpr&fenlei=-w9Uz4Bmy-bIi4WUvYETgN-" target="_blank" class="-highlight">bin</a>這樣就可以直接運行git命令了。

『陸』 如何搭建linux git伺服器

首先我們分別在Git伺服器和客戶機中安裝Git服務程序(剛剛實驗安裝過就不用安裝了):
[root@linuxprobe ~]# yum install git
Loaded plugins: langpacks, proct-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package git-1.8.3.1-4.el7.x86_64 already installed and latest version
Nothing to do

然後創建Git版本倉庫,一般規范的方式要以.git為後綴:
[root@linuxprobe ~]# mkdir linuxprobe.git

修改Git版本倉庫的所有者與所有組:
[root@linuxprobe ~]# chown -Rf git:git linuxprobe.git/

初始化Git版本倉庫:
[root@linuxprobe ~]# cd linuxprobe.git/
[root@linuxprobe linuxprobe.git]# git --bare init
Initialized empty Git repository in /root/linuxprobe.git/

其實此時你的Git伺服器就已經部署好了,但用戶還不能向你推送數據,也不能克隆你的Git版本倉庫,因為我們要在伺服器上開放至少一種支持Git的協議,比如HTTP/HTTPS/SSH等,現在用的最多的就是HTTPS和SSH,我們切換至Git客戶機來生成SSH密鑰:
[root@linuxprobe ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
65:4a:53:0d:4f:ee:49:4f:94:24:82:16:7a:dd:1f:28 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| .o+oo.o. |
| .oo *.+. |
| ..+ E * o |
| o = + = . |
| S o o |
| |
| |
| |
| |
+-----------------+

將客戶機的公鑰傳遞給Git伺服器:
[root@linuxprobe ~]# ssh--id 192.168.10.10
[email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.10.10'"
and check to make sure that only the key(s) you wanted were added.

此時就已經可以從Git伺服器中克隆版本倉庫了(此時目錄內沒有文件是正常的):
[root@linuxprobe ~]# git clone [email protected]:/root/linuxprobe.git
Cloning into 'linuxprobe'...
warning: You appear to have cloned an empty repository.
[root@linuxprobe ~]# cd linuxprobe
[root@linuxprobe linuxprobe]#

初始化下Git工作環境:
[root@linuxprobe ~]# git config --global user.name "Liu Chuan"
[root@linuxprobe ~]# git config --global user.email "[email protected]"
[root@linuxprobe ~]# git config --global core.editor vim

向Git版本倉庫中提交一個新文件:
[root@linuxprobe linuxprobe]# echo "I successfully cloned the Git repository" > readme.txt
[root@linuxprobe linuxprobe]# git add readme.txt
[root@linuxprobe linuxprobe]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached ..." to unstage)
#
# new file: readme.txt
#
[root@linuxprobe linuxprobe]# git commit -m "Clone the Git repository"
[master (root-commit) c3961c9] Clone the Git repository
Committer: root
1 file changed, 1 insertion(+)
create mode 100644 readme.txt
[root@linuxprobe linuxprobe]# git status
# On branch master
nothing to commit, working directory clean

但是這次的操作還是只將文件提交到了本地的Git版本倉庫,並沒有推送到遠程Git伺服器,所以我們來定義下遠程的Git伺服器吧:
[root@linuxprobe linuxprobe]# git remote add server [email protected]:/root/linuxprobe.git

將文件提交到遠程Git伺服器吧:
[root@linuxprobe linuxprobe]# git push -u server master
Counting objects: 3, done.
Writing objects: 100% (3/3), 261 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/root/linuxprobe.git
* [new branch] master -> master
Branch master set up to track remote branch master from server.

為了驗證真的是推送到了遠程的Git服務,你可以換個目錄再克隆一份版本倉庫(雖然在工作中毫無意義):
[root@linuxprobe linuxprobe]# cd ../Desktop
[root@linuxprobe Desktop]# git clone [email protected]:/root/linuxprobe.git
Cloning into 'linuxprobe'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[root@linuxprobe Desktop]# cd linuxprobe/
[root@linuxprobe linuxprobe]# cat readme.txt
I successfully cloned the Git repository

這篇是詳細介紹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 [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 怎麼用

Git服務程序中提交數據、移除數據、移動數據、查詢歷史記錄、還原數據及管理標簽等,滿足日常工作的需求。
同時還為包括了分支結構的創建與合並,遇到分支內容沖突的解決辦法,動手部署Git伺服器及使用Github託管服務等一些強大的功能,你可以參考下
一、在正式使用前,我們還需要弄清楚Git的三種重要模式,分別是已提交、已修改和已暫存:
已提交(committed):表示數據文件已經順利提交到Git資料庫中。
已修改(modified):表示數據文件已經被修改,但未被保存到Git資料庫中。
已暫存(staged):表示數據文件已經被修改,並會在下次提交時提交到Git資料庫中。
提交前的數據文件可能會被隨意修改或丟失,但只要把文件快照順利提交到Git資料庫中,那就可以完全放心了,流程為:
1.在工作目錄中修改數據文件。
2.將文件的快照放入暫存區域。
3.將暫存區域的文件快照提交到Git倉庫中。
執行yum命令來安裝Git服務程序:
[root@linuxprobe ~]# yum install -y git
Loaded plugins: langpacks, proct-id, subscription-manager
………………省略部分安裝過程………………
Installing:
git x86_64 1.8.3.1-4.el7 rhel7 4.3 M
Installing for dependencies:
perl-Error noarch 1:0.17020-2.el7 rhel7 32 k
perl-Git noarch 1.8.3.1-4.el7 rhel7 52 k
perl-TermReadKey x86_64 2.30-20.el7 rhel7 31 k
………………省略部分安裝過程………………
Complete!

首次安裝Git服務程序後需要設置下用戶名稱、郵件信息和編輯器,這些信息會隨著文件每次都提交到Git資料庫中,用於記錄提交者的信息,而Git服務程序的配置文檔通常會有三份,針對當前用戶和指定倉庫的配置文件優先順序最高:
配置文件 作用
/etc/gitconfig 保存著系統中每個用戶及倉庫通用配置信息。
~/.gitconfig
~/.config/git/config 針對於當前用戶的配置信息。
工作目錄/.git/config 針對於當前倉庫數據的配置信息。

第一個要配置的是你個人的用戶名稱和電子郵件地址,這兩條配置很重要,每次 Git 提交時都會引用這兩條信息,記錄是誰提交了文件,並且會隨更新內容一起被永久納入歷史記錄:
[root@linuxprobe ~]# git config --global user.name "Liu Chuan"
[root@linuxprobe ~]# git config --global user.email "[email protected]"

設置vim為默認的文本編輯器:
[root@linuxprobe ~]# git config --global core.editor vim

嗯,此時查看下剛剛配置的Git工作環境信息吧:
[root@linuxprobe ~]# git config --list
user.name=Liu Chuan
[email protected]
core.editor=vim

二、提交數據
我們可以簡單的把工作目錄理解成是一個被Git服務程序管理的目錄,Git會時刻的追蹤目錄內文件的改動,另外在安裝好了Git服務程序後,默認就會創建好了一個叫做master的分支,我們直接可以提交數據到了。
三、移除數據
有些時候會向把已經添加到暫存區的文件移除,但仍然希望文件在工作目錄中不丟失,換句話說,就是把文件從追蹤清單中刪除。
移動數據
Git不像其他版本控制系統那樣跟蹤文件的移動操作,如果要修改文件名稱,則需要使用git mv命令:
[root@linuxprobe linuxprobe]# git mv readme.txt introction.txt

由於字數限制,不能完全放下,如果你想好好了解,建議你看下http://www.linuxprobe.com/chapter-21.html 這個文檔中有詳細的用法你可以看看對你有用嗎

『玖』 如何在 Linux 上安裝 git 服務

Git 最初是一個在Linux下開發的非常流行的開源的版本控制系統(VCS)。與其他的VCS工具(如CVS或者SVN)不同,Git在某種意義上考慮的是「分布式」,你本地的Git工作目錄就可以作為一個完整的版本控制庫並具有版本跟蹤能力。在這種模式中,每一個協作者都可以提交到本地倉庫,並且如果需要的話可以有選擇的推送到一個集中的版本倉庫。這種可擴展性和冗餘的修訂控制系統是任何類型的大型協作任務中都是必須的。
一、通過包管理器安裝 Git
Git 是所有主要的Linux發行版本都附帶的功能。因此,安裝Git的最簡單的方法是使用您的Linux發行版的包管理器。
Debian, Ubuntu, or Linux Mint
$ sudo apt-get install git

Fedora, CentOS or RHEL
$ sudo yum install git

Arch Linux
$ sudo pacman -S git

OpenSUSE
$ sudo zypper install git

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

二、從源代碼安裝Git
如果出於某種原因你想從源代碼安裝Git,你可以遵循下面的說明。
安裝依賴
構建之前,首先安裝Git依賴。
Debian,Ubuntu or Linux
$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto docbook2x

Fedora, CentOS or RHEL
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2x

從源代碼編譯Git
從 https://github.com/git/git/releases 下載最新版本的 Git,然後在 /usr 目錄下構建和安裝 Git。
注意,如果你想安裝在一個其他的目錄(如 /opt ),可以替換配置命令行中的 「--prefix=/usr 」。
$ cd git-x.x.x
$ make configure
$ ./configure --prefix=/usr
$ make all doc info
$ sudo make install install-doc install-html install-info

熱點內容
日產高配有哪些配置 發布:2025-05-12 10:32:16 瀏覽:474
大眾朗逸哪個配置值得入手 發布:2025-05-12 10:31:20 瀏覽:503
壓縮包的後綴 發布:2025-05-12 10:20:35 瀏覽:939
煙台招聘編程 發布:2025-05-12 10:04:21 瀏覽:52
sql查詢所有表名 發布:2025-05-12 10:01:28 瀏覽:663
用python編譯器的簡單代碼 發布:2025-05-12 09:48:40 瀏覽:357
香港多ip站群伺服器租用 發布:2025-05-12 09:33:16 瀏覽:894
kaliapk編譯 發布:2025-05-12 08:47:56 瀏覽:357
健身穿壓縮衣 發布:2025-05-12 08:44:53 瀏覽:479
vps撥號伺服器搭建 發布:2025-05-12 08:35:20 瀏覽:310