Loading

Github教程(0)

作者:Grey

原文地址:Github教程(0)

Git下载:https://git-for-windows.github.io/

我下载的版本是:Git-2.6.3-64-bit.exe

安装:略 默认选项点击"下一步"即可

安装完毕后

  1. 打开Git Bash

    设置使用Git时候的名字和邮箱地址

    $ git config --global user.name "yourname"
    $ git config --global user.email "youremail@email.com"
    
  2. 注册Github账户:https://github.com/

  3. 设置SSH Key,在Git Bash中输入:

    ssh-keygen –t rsa –C "github register email"
    

    注: github register email这里写你在第二步注册Github账户的邮箱地址

    然后按下回车,并设置认证密码(也可不设置)

    回车,会得到两个文件:id_rsa(私有密钥),id_rsa.pub是公开密钥。

    这两个文件默认在C:\Users\Username.ssh目录下

  4. 添加公开密钥:

    进入你的Github账户,在右上角选择Setting->SSH keys->Add SSH key, 其中,Title输入一个名称,在Key处粘贴id_rsa.pub中的内容。

  5. 此时就可以用私人密钥和Github进行认证和通信,在Git Bash中输入:

    ssh –T [git@github.com](mailto:git@github.com)
    

    提示:Are you sure you want to continue connecting (yes/no)?

    输入:yes 回车

    显示:Hi yourname! You've successfully authenticated, but Github does not provide shell access.

接下来,演示一个Github的HelloWorld示例:

  • 进入Github账户,点击New repository
  • Repository name输入Hello
  • Description项输入一些对仓库的描述信息(选填)
  • Public/Private选项勾选Public
  • Initialize this repository with a README 选项选上
  • 点击Create Repository即可创建一个Repository
  • 点击进入Hello这个Repository,拷贝这个Repository的Web Address

将Hello这个Repository clone至本地,打开Git Bash,输入:

git clone your repository's Web Address

提示:repository's Web Address就是上一步骤拷贝的URL

Git Bash输入,

cd Hello

在Hello目录下增加一个文件,比如T.java

将T.java添加到暂存区,Git Bash中输入:

git add T.java

提交T.java, Git Bash中输入:

git commit –m "this is your comment"

Push到Github上的仓库

git push

进入Github账户中的Hello Repository,即可查看push进去T.java这个文件

查看提交日志:

git log
posted @ 2015-12-14 22:43  Grey Zeng  阅读(1079)  评论(2编辑  收藏  举报