Github入门教程

10 篇文章 0 订阅
3 篇文章 0 订阅
  作者: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). 当第三步成功后,就可以进行本地的开发测试,提交代码等一系列操作。比如完成第一次提交动作:

  1. 进入工作目录wadetest;
  2. 创建新文件index2.js;
  3. 提交index2.js到本地仓库;
  4. 将本地修改分支master同步到服务器git@github.com:billfeller/wadetest.git;

具体操作如下:

[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). 至此,你的第一次提交就算完成了。

推荐阅读:

《精通Git》progit-cn.pdf

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值