Github入门教程
作者:zhanhailiang 日期:2014-11-06
本文将教读者如何使用Github代码托管服务快速创建项目和提交代码。
1. 去github.com注册帐号,略;
2. 在github.com设置里添加SSH公钥:
1). 需要在本地(linux)环境中下查看是否已生成公钥;SSH公钥默认储存在账户的主目录下的/.ssh目录,如下:
[root@~/.ssh]# ls id_rsa id_rsa.pub known_hosts
一般默认id_rsa.pub就是指公钥,id_rsa是你本地的密钥;若没有,请使用ssh-keygen工具生成即可;
当获取到公钥后,请将公钥内容 Add SSH Key即可:
2). 接下来请在github.com上创建新仓库,举例创建名为wadetest仓库:
3). 在本地克隆wadetest仓库:
[root@~/wade]# git clone git@github.com:billfeller/wadetest.git Initialized empty Git repository in /root/wade/wadetest/.git/ remote: Counting objects: 6, done. remote: Compressing objects: 100% (3/3), done. remote: Total 6 (delta 0), reused 3 (delta 0) Receiving objects: 100% (6/6), done.
4). 当第三步成功后,就可以进行本地的开发测试,提交代码等一系列操作。比如完成第一次提交动作:
- 进入工作目录wadetest;</li>
- 创建新文件index2.js;
- 提交index2.js到本地仓库;
- 将本地修改分支master同步到服务器git@github.com:billfeller/wadetest.git; </ol>
具体操作如下:
[root@~/wade]# cd wadetest/ [root@~/wade/wadetest]# ls index.js README.md [root@~/wade/wadetest]# touch index2.js [root@~/wade/wadetest]# git add index2.js [root@~/wade/wadetest]# git commit -m 'first commit' [master ce86c0b] first commit Committer: root <root@AY140321223706700af3Z.(none)> Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email you@example.com If the identity used for this commit is wrong, you can fix it with: git commit --amend --author='Your Name <you@example.com>' 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 index2.js [root@~/wade/wadetest]# git remote -v origin git@github.com:billfeller/wadetest.git (fetch) origin git@github.com:billfeller/wadetest.git (push) [root@~/wade/wadetest]# git branch * master [root@~/wade/wadetest]# git push git@github.com:billfeller/wadetest.git master Counting objects: 3, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 277 bytes, done. Total 2 (delta 0), reused 0 (delta 0) To git@github.com:billfeller/wadetest.git c46ad6c..ce86c0b master -> master
5). 至此,你的第一次提交就算完成了。
推荐阅读:
</div> 来自:http://blog.csdn.net/billfeller/article/details/40841179 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!