根据《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)