(二)Git安裝和環境設定

2021-07-09 04:23:28 字數 1945 閱讀 1487

如果使用的是gnu/ linux 發行版debian基本apt-get命令就可以搞定一切。

[ubuntu ~]$ sudo apt-get install git-core

[sudo] password for ubuntu:

[ubuntu ~]$ git --version

git version 1.8.1.2

而且,如果使用的是基於rpm的gnu/ linux發行版使用yum命令,如下:

[centos ~]$

su -

password:

[centos ~]# yum -y install git-core

[centos ~]# git --version

git version 1.7.1

git提供git 的配置工具,它允許設定配置變數。 git會把所有的全域性配置.gitconfig 檔案位於主目錄。要設定這些為全域性配置值,新增 -global選項,如果省略 -global選項,那麼配置是具體當前的git儲存庫。

還可以設定系統範圍內的配置。 git儲存這些值是在/etc/gitconfig檔案,其中包含的配置系統上的每乙個使用者和資源庫。要設定這些值,必須有root許可權,並使用 -system 選項。

上面的**編譯和執行時,它會產生以下結果:

此資訊用於git的每個提交。

[jerry@centos project]$ git config --global user.name "jerry mouse"

此資訊用於git的每個提交。

[jerry@centos project]$ git config --global user.email "[email protected]"

先從遠端資源庫的最新變化,如果這些變化是不同的,預設情況下,git 建立合併提交。我們可以通過以下設定來避免這種。

jerry@centos project]$ git config --global branch.autosetuprebase always

下面的命令使顏色突出顯示在控制台的git。

[jerry@centos project]$ git config --global color.ui true

[jerry@centos project]$ git config --global color.status auto

[jerry@centos project]$ git config --global color.branch auto

預設情況下,git的使用系統預設取自visual或editor環境變數的編輯器。我們可以設定乙個不同的使用git 配置。

[jerry@centos project]$ git config --global core.editor vim

git不會提供乙個預設的合併工具整合到工作樹衝突的更改。我們可以設定預設的合併工具,通過啟用以下設定。

[jerry@centos project]$ git config --global merge.tool vimdiff

為了驗證自己的git設定本地儲存庫使用git 的config-list命令,如下所示。

[jerry@centos ~]$ git config --list

上面的命令會產生以下結果。

user.name=jerry mouse

[email protected]

push.default=nothing

branch.autosetuprebase=always

color.ui=true

color.status=auto

color.branch=auto

core.editor=vim

merge.tool=vimdiff

Git 環境設定(安裝)

在使用git之前,必須安裝它,並做一些基本配置的變化。下面是步驟在ubuntu和centos linux安裝 git 客戶端。如果使用的是gnu linux 發行版debian基本apt get命令就可以搞定一切。ubuntu sudo apt get install git core sudo p...

mac環境下,git安裝和使用

選擇對應的版本,安裝即可 檢視git版本 git version 安裝homebrew usr bin ruby e curl fssl homebrew安裝完成以後檢查一下 brew v 通過brew來安裝git brew install git安裝完成以後即可使用git version來檢視版本...

Linux環境安裝git

使用coding管理專案,上面要求使用的git版本為1.8.0以上,而很多yum源上自動安裝的git版本為1.7,所以需要掌握手動編譯安裝git方法。yum install curl devel expat devel gettext devel openssl devel zlib devel g...