天天看点

使用github托管代码

使用命令行操作的过程如下:

参考http://1ke.co/course/194

1.注册github账号了。之后就可以创建仓库了(免费用户只能建公共仓库),Create a New Repository;

github是服务端,要想在自己电脑上使用git我们还需要一个git客户端,windows用户请下载 http://msysgit.github.com/

2.运行git shell命令行窗口,切换到要打算上传的文件夹下,

(1)先执行git init命令:git init 注意:初次使用时,要进行(2)~(5)步骤

(2)在本地创建ssh key:ssh-keygen -t rsa -C "[email protected]"

(3)进入提示的地址下查看ssh key文件。回到github网站,进入Account Settings,左边选择SSH Keys,Add SSH Key,

(4)验证是否成功,在git bash下输入:ssh -T [email protected]

(5)还需要设置username和email,因为github每次commit都会记录他们

git config --global user.name "your name"
git config --global user.email "[email protected]"              (6)添加远程地址:git remote add origin [email protected]:yourName/yourRepo,yourName和yourRepo表示你github的用户名和新建的仓库              (7)提交所有文件或某个文件:git add . 或 git add README              添加注释内容:git commit -m "first commit"
              (8)git pull origin master // 先把远程服务器github上面的文件拉下来,再push 上去              上传到github:git push origin master              使用图形窗口操作的过程更直观简单