GitHub配置步骤和简单的git关联

通过git书籍学习

1. 创建账户(username:Flora)

2. 设置头像(不是必须)

3. 设置SSH Key

  $ssh-keygen -t rsa -C "email@email.com" //创建用户时使用的邮箱 -> 回车 -> 密码 -> 密码

  生成id_rsa私有密钥,id_rsa.pub公开密钥

4. 添加公开密钥

  右上角 -> Account Settings -> SSH Key -> Add SSH Key -> title适当,key是id_rsa.pub里面的内容(用cat ~/.ssh/id_rsa.pub -> ssh-rsa 公开密钥内容 email@email.com)

  ->测试 ssh -T email@email.com, 输入yes

5. 使用

  右上角 -> New repository创建一个新库(repository name: hello-world) -> 注意: "Initialize this respository with a readme", 自动初始化库并设置Readme文件,让用户可以立即clone这个仓库。如果向GitHub添加手中已有的git仓库,不建议勾选,直接手动push -> 链接才仓库(https://github.com/Flora用户名/hello-world库名)-> readme.md文件显示项目等信息,可以用MarkDown语法进行描述,添加标记,提高可读性。

6. 将已有的仓库clone到身边的开发环境中。找到SSH clone URL,将内容复制, git clone 复制的内容

  SSH clone URL: git@github.com:Flora/hello-world.git 输入创建key时的密码

  git clone git@github.com:Flora/hello-world.git

  cd hello-world

  添加一个文件hello_world.php

  git add hello_world.php 将文件放到暂存区(在Index数据结构中记录问价提交之前的状态)

  git commit -m 'Add hello_world file' 提交

  git log 查看提交日志

  git push 如果建立了分支(git branch develop)使用git push origin master

  

posted @ 2016-02-01 17:50  李晓菲  阅读(257)  评论(0编辑  收藏  举报