github快速入门(一)

一、github介绍

  git是一款非常知名的代码托管工具。当然现在有了github for windows版本(类似于 svn tortoise).

  GitHub for Windows 是一个 Metro 风格应用程序,集成了自包含版本的 Git,bash 命令行 shell,PowerShell 的 posh-git 扩展。GitHub 为 Windows 用户提供了一个基本的图形前端去处理大部分常用版本控制任务,可以创建版本库,向本地版本库递交补丁,在本地和远程版本库之间同步。微软也通过CodePlex向开发者提供 git 版本控制系统,而 GitHub 创造了一个更具有吸引力的 Windows 版本。

当然,你可以使用这个客户端代替繁琐的命令。可以使用git bash 命令行shell 下载 github for windows

安装使用,这里就不介绍了。具体可以参考 http://www.ihref.com/read-16514.html 。本文不讲如何使用客户端,而是教你学会用命令搭建,包括ssh key生成

二、github管理界面 官网

1、注册 : 记住邮箱

2、git初始化账户|密码

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

3、随便找一个目录,右击 git bash(前提你要安装过github for windows), 生成ssh key秘钥

ssh-keygen -t rsa -C"你的邮箱"

如果成功的话,会在~/ 目录下创建 .ssh 目录

进入~/.ssh/目录 vim  id_rsa.pub 。将 id_rsa.pub的内容copy

4、进入github个人设置页面。Settings -- 》 ssh and GPG keys --》 new ssh key --> 将 id_rsa.pub的内容copy至key即可

 

 5、验证ssh key 是否生效

ssh -T git@github.com

结果可能会出现如下

The authenticity of host 'github.com (192.30.253.112)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?

输入 yes

Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Hi xpw! You've successfully authenticated, but GitHub does not provide shell access.

这就代表成功了

6、马上撸一发。看看github是怎么托管代码的

①、创建仓库 repository

②、将远程分支拉取下来

 git clone "https://github.com/xpw/gitDemo.git"

结果

Cloning into 'gitDemo'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

 然后进入工程目录gitDemo目录下

随便加个文件 test.txt , vi test.txt 打开后编辑hi,git !

提交code到本地缓存区 git commit a -m'注释说明'

提交到远程github上,git push origin master。这时会要求你输入用户名(github用户名)、密码(github注册的密码)

③、我们在github上就可以看到刚才提交的code记录

原文地址:https://www.cnblogs.com/chenmo-xpw/p/5657810.html