根據《GotGitHub》【1】所作的一些整理html
在GitHub的頁面中可使用鍵盤快捷鍵git
(1)按下問號(?)會在彈出窗口顯示當前頁面可用的快捷鍵。github
(2)在項目的代碼瀏覽頁按下字母「w」,彈出分支切換菜單。markdown
(3)按下字母「t」,開啓目錄樹中文件查找和過濾。網絡
有2種辦法:(1)在GitHub建立新項目;(2)從已有版本庫建立,而後 remote push到GitHub網站
(1)在GitHub首頁 「New repository」,建立新版本庫 HelloWorldthis
(2)在本地使用Git Bash,將repository clone到本地。spa
$ git clone https://github.com/zhchnchn/HelloWorld.git.net
(3)在本地HelloWorld目錄下建立 README.md 文件。命令行
以擴展名.md,.mkd,.mkdn,.mdown,.markdown等爲結尾的文件,均以Markdown標記語言語法進行解析並顯示。
(4)添加README.md文件並提交。
$ git add README.md
$ git commit -m "README for this project."
(5)向GitHub推送,完成版本庫初始化。
$ git push origin master
(6)而後刷新GitHub上HelloWorld項目的首頁,可見版本庫包含了一個新的提交。
(7)如何刪除建立的版本庫?
在HelloWorld項目首頁的右方,點擊」Settings「->在紅色的」Danger Zone「區域,點擊」Delete this repository「->輸入項目名HelloWorld確認刪除。
若是本地clone的版本庫不須要了,則手動刪除之。
(1)使用Git Bash在本地創建一個Git版本庫。
$ mkdir HelloWorld
$ cd HelloWorld
$ git init
(2)而後在版本庫中添加README.md文件
$ git add README.md
$ git commit -m "README for this project."
(3)爲版本庫添加名爲origin的遠程版本庫
$ git remote add origin git@github.com:zhchnchn/HelloWorld.git
(4)執行推送命令,完成GitHub版本庫的初始化。注意命令行中的-u參數,在推送成功後自動創建本地分支與遠程版本庫分支的追蹤。
$ git push -u origin master
注:這一步沒有成功,顯示錯誤信息。
remote: Repository not found.
fatal: repository 'https://github.com/zhchnchn/HelloWorld.git/' not found
嘗試了不少種方法都沒有解決,有可能公司網絡防火牆禁止了SSH操做。
2014-05-20,NOTE:
換了另一種方式成功了:
(1)-(2)步驟與前面相同
(3)爲版本庫添加名爲origin的遠程版本庫
$ git remote add origin https://github.com/zhchnchn/HelloWorld.git
(4)執行推送命令
$ git push origin master
提示錯誤:
remote: Repository not found.
fatal: repository 'https://github.com/zhchnchn/HelloWorld.git/' not found
(5)在GitHub主頁建立HelloWorld倉庫,注意不要添加README.md等任何文件。
(6)建立完成後,再次git push origin master,此次終於成功了。
$ git push origin master Counting objects: 12, done. Delta compression using up to 4 threads. Compressing objects: 100% (12/12), done. Writing objects: 100% (12/12), 25.02 KiB | 0 bytes/s, done. Total 12 (delta 4), reused 0 (delta 0) To https://github.com/zhchnchn/HelloWorld.git * [new branch] master -> master
2014-05-21,NOTE:
在 http://www.cnblogs.com/plinx/archive/2013/04/08/3009159.html中提到,使用 SSH來git remote add origin時,出現了Repository not found的問題。而在我本機上SSH不能夠,HTTPS能夠。說明我本機不支持SSH協議。
開發者向GitHub版本庫寫入最經常使用到的協議是SSH協議,由於SSH協議使用公鑰認證,能夠實現無口令訪問,而若使用HTTPS協議每次身份認證時都須要提供口令.
可是,能夠經過在文件~/.netrc中寫入明文口令實現使用 HTTPS 協議時也能自動完成認證。具體格式參見ftp命令的MAN手冊中相關介紹。
具體設置參見:http://www.cnblogs.com/zhcncn/p/3681209.html -- 如何配置,在向Github去 git push 時不用輸入用戶名密碼?
GitHub 爲每個用戶分配了一個二級域名<user-id>.github.io,用戶爲本身的二級域名建立主頁很容易,只要在託管空間下建立一個名爲<user-id>.github.io的版本庫,向其master分支提交網站靜態頁面便可,其中網站首頁爲index.html.
訪問網址: http://gotgithub.github.io/
要注意訪問用戶二級域名的主頁要使用HTTP協議非HTTPS協議.
GitHub會爲每一個帳號分配一個二級域名<user-id>.github.io做爲用戶的首頁地址。實際上還能夠爲每一個項目設置主頁,項目主頁也經過此二級域名進行訪問。例如gotgithub用戶建立的helloworld項目若是啓用了項目主頁,則可經過網址http://gotgithub.github.io/helloworld/訪問.
爲項目啓用項目主頁很簡單,只須要在項目版本庫中建立一個名爲gh-pages的分支,並向其中添加靜態網頁便可。
【1】GotGitHub (http://www.worldhello.net/gotgithub/index.html)
【2】在不一樣電腦上git push同個github帳戶下的repositories(http://yulijia.net/cn/%E7%9F%A5%E8%A1%8C%E5%B9%B6%E8%BF%9B/2013/02/06/use-one-github-account-on-two-computers.html)