GitHub基本使用方法
GitHub基本使用方法
1.在https://github.com/上注册一个账号;
2.下载安装git客户端:http://msysgit.github.io/,当然如果你的下载速度过慢,可以从胡老师他们的服务器上下载(我就是在这上面下的):http://resources.ynu.edu.cn/Git-2.10.1-64-bit.exe(64位)http://resources.ynu.edu.cn/Git-2.10.1-32-bit.exe(32位)
安装过程参考胡老师上次小课关于持续集成讲的git安装方法,http://www.jianshu.com/p/9d8b385cf5fa;
3.安装好Git后,启动命令行,输入git,出现如下界面:

Ok,安装成功。
然后设置username和email:
`git config --global user.name "your name"`
`git config --global user.email "your_email@youremail.com"`
4.现在,生成你的公钥,在命令行中输入: `ssh-keygen –t rsa –C “your@email.address”`(注意字符均为英文字符)。在这里我们默认目录,在生成公钥时会提示你目录,一般在“C:\Documents and Settings\Airen\.ssh”的“id_rsa.pub”中,也许你可能找不到“.ssh”文件夹,那是因为系统把它隐藏了,你需要在文件夹选项中开启查看隐藏文件夹,然后用记事本打开该文件,复制全部内容。
5.登入你的github, 点击这里:

点击左侧SSH and GPG keys,点击new SSH keys添加你的公钥,如下图所示:


6.现在你可以建立你的代码仓库了:


点击右上的new按钮新建仓库:

7.进入你刚才创建的仓库:

8.克隆仓库到本地:
在命令行中cd到你的仓库目录,使用gitclone克隆的仓库,用法:
git clone http://.地址...;
使用ls列出当前文件夹的文件:

选择你要修改的文件或者添加新文件,比如我们用记事本打开README:

然后我们用git status来查看当前目录中文件的状态,

Modified表示你修改了文件,但是还未加入控制,我们用git add把他加入控制:

看,它变成了绿色,是的我们已经把它加入控制了,然后我们再使用git commit把它提交到仓库:

好了,现在我们已经把它加入到仓库了,我们来看看它的状态:

现在可以推送了,还记得我们前面说的那个克隆的地址吗?对了,就是那个唯一的地址,现在我们要用到它了:

推送过程可能会慢点,现在我们来看看结果,进入你的github,找到你刚才建立的仓库,刷新一下试试:


好了,基本的用法就这样了,你可以上传你的代码了。其实github不仅可以用来管理你的代码,你还可以上传你的文档,比如你要写一个大大的文档,你就可以把你的文档上传上去,避免丢失,用它来管理你的文档,github可以做的远不止这些哦。