http://www.cnblogs.com/fnng/archive/2011/08/25/2153807.html
1. git 版本控制系統
相比CVS\SVN優勢:
- 支持離線開發,離線Repository
- 強大的分支功能,適合多個獨立開發者協作
- 速度塊
ps:關於git的更詳細的介紹於優點在此就不介紹了,教大家怎麼用是關鍵。:)
==============運行環境========
系統:windows
git : Git-1.7.3.1-preview20101002.rar 下載地址:http://d.download.csdn.net/down/3169511/z_y_liu89
===========================
2. github是一個git項目託管網站
註冊地址:https://github.com/signup/free
3. 安裝git程序,執行下面操作
$ cd ~/.ssh //檢查計算機ssh密鑰
如果沒有提示:No such file or directory 說明你不是第一次使用git,執行下面的操作,清理原有ssh密鑰
$ ls
config id_rsa id_rsa.pub known_hosts
$ mkdir key_backup
$ cp id_rsa* key_backup
$ rm id_rsa*
獲得密鑰:
ssh-keygen -t rsa -C "[email protected]"//填寫email地址,然後一直“回車”ok
打開本地..\.ssh\id_rsa.pub文件。此文件裏面內容爲剛纔生成人密鑰。
4. 登陸github系統。點擊右上角的 Account Settings--->SSH Public keys ---> add another public keys
把你本地生成的密鑰複製到裏面(key文本框中), 點擊 add key 就ok了
5. 接着打開git ,測試連接是否成功
$ ssh -T [email protected]
如果提示:Hi defnngj You've successfully authenticated, but GitHub does not provide shell access. 說明你連接成功了
6. 設置用戶信息:
6.1
$ git config --global user.name "defnngj"//給自己起個用戶名
$ git config --global user.email "[email protected]"//填寫自己的郵箱
6.2
在github中找到 Account Settings--->Account Admin ,找到一下信息:
Your API token is e97279836f0d415a3954c1193dba522f ---keep it secret! Changing your password will
generate a new token
$ git config --global github.user defnngj //github 上的用戶名
$ git config --global github.token e97279836f0d415a3954c1193dba522f
====================創建一個項目========================
1. 回到github首頁,點擊頁面右下角“New Repository”
填寫項目信息:
project name: hello world
description : my first project
點擊“Create Repository” ; 現在完成了一個項目在github上的創建。
2. 我們需要使用git在本地創建一個相同的項目。
$ makdir ~/hello-world //創建一個項目hello-world
$ cd ~/hello-world //打開這個項目
$ git init //初始化
$ touch README
$ git add README //更新README文件
$ git commit -m 'first commit'//提交更新,並註釋信息“first commit”
$ git remote add origin [email protected]:defnngj/hello-world.git //連接遠程github項目
$ git push -u origin master //將本地項目更新到github項目上去
現在查看github上面的hello world 項目,是不是發現已經將本地中的README文件更新上來了。 :) 恭喜!
------------------------------------關於可能出現的錯誤----------------------------------
1.在執行
$ git remote addorigin [email protected]:defnngj/hello-world.git
錯誤提示:fatal: remote origin already exists.
解決辦法:
$ git remote rm origin
然後在執行:$ git remote add origin [email protected]:defnngj/hello-world.git 就不會報錯誤了
2. 在執行
$ git push origin master
錯誤提示:error:failed to push som refs to.......
解決辦法:
$ git pull origin master //先把遠程服務器github上面的文件拉先來,再push 上去。
---------------------------後記-----------------------------------------------------------------------
本文是參考官方幫助進行的:http://help.github.com/win-set-up-git/ 基本與官方步驟相同,我在此屬於翻譯了一下!
關於更過的學習:請登陸: http://progit.org/book/zh/進行學習。
本來關於此類知識應該屬於開發的,本人從事測試工作,因爲老大現在在推行git的使用,所以,就花了時間,初步的學習了一下,爲了更好的測試嘛。呵呵。
第二個原因,看到有個樂師用版本管理系統(SVN)來更新和管理自己的樂譜,這個很有意思。版本管理系統並不侷限於代碼的管理。而且版本管理系統的思想也很有意思。
關於理論上的東西,請參考其它文檔。
|