Mac OS X Git安裝教程

來源:互聯網
上載者:User

原文連結:http://www.cnblogs.com/ccdev/archive/2012/09/12/2682098.html


下載:http://code.google.com/p/git-osx-installer/

下載最新的PGK檔案。

圖形化OpeninGitGui:

http://code.google.com/p/git-osx-installer上也提供了一個Git的圖形化用戶端:OpenInGitGui,可以從這裡獲得,OpenInGitGui十分小巧,下載解壓後也只有16K,OpenInGitGui不用安裝,雙擊即可使用,OpenInGitGui剛啟動時,會記錄開啟過的資產庫。

github使用SSH連結,需要設定SSH

1.檢查SSH key

     cd ~/.ssh

2.備份已有的key,(如果有的話)

     mkdir key_backup

     mv id_rsa* key_backup

3.產生SSH key

$ ssh-keygen -t rsa -C jonezhang86@gmail.com

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/jiangbo/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in yes.

Your public key has been saved in id_rsa.pub.

The key fingerprint is:

fb:c4:b0:e0:47:fd:be:e0:fb:ea:73:ef:a8:29:d5:22 jonezhang86@gmail.com

The key's randomart image is:

+--[ RSA 2048]----+

|                 |

|                 |

|                 |

|         .       |

|      . S ..     |

|     . oE=o..    |

|      . +o+..    |

|       ..+.+..   |

|         oOB=+o  |

+-----------------+

4.將SSH key添加到GitHub

登入到GitHub頁面,Account Settings->SSH Public Keys->Add another key

將產生的key(id_rsa.pub檔案)內容copy到輸入框中,save。

5.測試連結

$ ssh git@github.com

The authenticity of host 'github.com (207.97.227.239)' can't be established.

RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.

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

PTY allocation request failed on channel 0

Hi Jone Zhang! You've successfully authenticated, but GitHub does not provide shell access.

         Connection to github.com closed.

出現上述提示資訊說明串連成功(github並不提供shell登陸但已經串連成功)

三、設定個人資訊

$ git config --global user.name "Jone Zhang"

$ git config --global user.email jonezhang86@gmail.com

 

補充內容:

Mac
在 Mac 上安裝 Git 有多種途徑:最簡單的方法就是使用  Git OS X Installer。開啟 Google Code 上的 git-osx- installer 頁面,下載最新的安裝包。現在最新的是 Git 1.7.5。掛載 dmg 鏡像安裝 Git。 如果你想使用 Git GUI,那麼就運行 dmg 鏡像中的指令碼來安裝。 如果你想使用類似於 Homebrew 或者 MacPorts 的包管理來安裝,也是非常簡單的。

Homebrew

$ sudo brew install git

MacPorts

 

$ sudo port selfupdate$ sudo port install git-core

( sudo 是已 root 使用者權限運行命令;通常安裝軟體是需要。如果使用 sudo,命令列會要求輸入使用者密碼。)

如果想要更深入的體驗 Git,那麼就從原始碼安裝吧。首先,需要安裝 Apple Developer Tools – Xcode。可以在  http://developer.apple.com/mac/ 下載。
我們將 Git 安裝在 /usr/local 目錄下,確保 Terminal 可以在 $PATH 環境變數中找到。 檢查 /usr/ local/bin 路徑 ( bin 代表 binary,編譯的 Git 報存在子目錄中)。 如果不再,開啟 .profile 添加到最後。

export PATH=”/usr/local/bin:$PATH”

儲存關閉 .profile 檔案後,重啟 Terminal。運行 echo $PATH 應該看到 /usr/local/bin 在 $PATH 環境變數中。
現在我們可以開始安裝 Git 了,如果還不是很熟悉命令列,可以使用之前的方法安裝。如果沒有問題,開始吧。
下載並解壓 Git 原始碼:

$ curl -O http://kernel.org/pub/software/scm/git/git-1.7.5.tar.bz2$ tar xzvf git-1.7.5

開啟目錄,編譯 Git:

$ cd git-1.7.5$ ./configure --prefix=/usr/local$ make$ make install

完成。現在可以刪除這個目錄的了。

$ cd ..$ rm git-1.7.5$ rm git-1.5.1.tar.bz2

應該看到 Git 已經成功安裝,查看安裝位置:

$ which git

應該得到 /usr/local/bin/git。如果正確,就說明已經成功從原始碼安裝 Git!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.