github的初接觸

使用GitHub步驟:
一、申請GitHub賬戶 xxx ,建立名爲new-project的新Repository 

二、安裝Git客戶端(Linux)
#yum install git git-gui                 //我使用的是opensuse,直接在軟件倉庫搜索的git

三、 生成密鑰對,這樣項目能夠push到 GitHub上
#ssh-keygen -t rsa -C "你的郵箱地址"
四、將.ssh/id_rsa.pub拷貝到GitHub網站

在github,進入Account Settings,左邊選擇SSH Keys,Add SSH Key,title隨便填,粘貼key。

爲了驗證是否成功,在git bash下輸入:
  
$ ssh -T git@github.com

若是是第一次的會提示是否continue,輸入yes就會看到:You've successfully authenticated, but GitHub does not provide shell access 。這就表示已成功連上github。 php

五、爲了方便,設置ssh不輸入口令
# eval `ssh-agent`
# ssh-add
(輸入passphrase)

六、設置Git全局用戶配置
# git config --global user.name "你的名字"
# git config --global user.email 「你的郵箱地址」

七、建立本地新項目工做樹
# mkdir new-project
# cd new-project
# git init
# touch README
# git add README
# git commit -m 'first commit'
定義遠程服務器別名origin
#  git remote add origin git@github.com:xxx/new-project.git   
本地和遠程合併,本地默認分支爲master
# git push origin master  

GitHub網站上就能夠看見了。

8. 更新文件
# vi README
自動commit更改文件
# git commit -a     
更新至遠程
# git push origin master 



//暫時學習到這(2014.06.05)


9. 建立和合並分支 #git branch 顯示當前分支是master #git branch new-feature  建立分支 # git checkout new-feature 切換到新分支 # vi page_cache.inc.php # git add page_cache.inc.php Commit 到本地GIT # git commit -a -m "added initial version of page cache" 合併到遠程服務器 # git push origin new-feature 若是new-feature分支成熟了,以爲有必要合併進master #git checkout master #git merge new-feature #git branch #git push  則master中也合併了new-feature 的代碼
相關文章
相關標籤/搜索