Github使用教程(一)
来源:互联网 发布:java后端需要学node吗 编辑:程序博客网 时间:2024/06/13 21:36
Github使用教程(一)
本文大量参考《Github入门与实践》一书。转载请注明出处。
全文分为六个部分,主要内容概述如下
- 使用Github的前期准备
- git的介绍与使用
- github的主要功能
- 尝试Pull Request
- 使用GitHub的开发流程
- 将github应用到企业
使用Github的前期准备
设置SSH Key
Github上连接已有仓库的认证,是通过使用SSH的公开秘钥
运行下面的秘钥创建SSH Key$ ssh-keygen -t rsa -C "your_email@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key
(/Users/your_user_directory/.ssh/id_rsa): 按回车键
Enter passphrase (empty for no passphrase): 输入密码
Enter same passphrase again: 再次输入密码输入密码后会出现以下结果:
接着添加公开秘钥$ cat ~/.ssh/id_rsa.pub
ssh-rsa 公开密钥的内容 your_email@eaxample.com
完成以上后邮箱会收到邮件
然后接下来就可以用手中的私人秘钥与github进行认证和通信了。
让我们来实际试一试。$ ssh -T git@github.com The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is fingerprint值 . Are you sure you want to continue connecting (yes/no)? 输入yes
成功后Hi hirocastest! You've successfully authenticated, but GitHub does not provide shell access.
创建工程
因为不是新手教程前面的创建步骤就不详细介绍了。我们简要探讨
最后两个添加文件Add.gitignore和Add a license。
Add.gitignore主要作用是可忽视不需要版本控制的文件。
Add a license选择要添加的许可协议文件。clone已有仓库
接下来我们将尝试在已有仓库中添加代码并加以公开$ git clone git@github.com:hirocastest/Hello-World.git
Cloning into 'Hello-World'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done
这里要求输入Gitgub上设置的公开密钥的密码。认证成功后,仓库便会被clone至仓库名后的目录中。将要提交的代码放入这个仓库,最后push到Github仓库中,代码便会公开。提交
新建一个hello_word文件提交至仓库,这个文件就会进入版本控制之下,之后的管理都可以用git进行$ git add hello_world.php
$ git commit -m "Add hello world script by php"
[master d23b909] Add hello world script by php
create mode 100644 hello_world.php进行push
之后只要执行push就能更新GitHub上的仓库。
$ git push
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 328 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:hirocastest/Hello-World.git 46ff713..d23b909 master -> master
这样就完成了使用git上传代码到github上
- Github使用教程(一)------ 初识Github
- Github使用教程(一)
- GitHub使用教程(一)
- GitHub for Windows使用教程(一)
- GitHub for Windows使用教程(一)
- Github客户端安装使用教程(一)
- GitHub教程(一)
- Github使用教程(一)--搭建Github环境
- AsyncHttpClient使用教程(一)(翻译自Github)
- GitHub for Windows使用教程(一)安装配置
- Git使用教程(一)--搭建Github环境
- Git使用教程(一)--搭建Github环境
- GitHub使用(一)
- GitHub使用(一)
- github使用教程(二)
- 学习使用github(一)
- GitHub使用笔记(一)
- 如何使用github?github简单使用教程(转)
- 上传图片 图片预览功能
- Rhino| Rhino的测试例子
- jquery的$().each,$.each的区别
- 根据不同访问设备跳转到PC页面或手机页面
- ZigBee TI ZStack CC2530 1.1 总体框架
- Github使用教程(一)
- LoadRunner12如何自动关联
- 基于Qt QGraphicsView的多点触摸绘图
- 关于idea
- Java Web
- 详细讲解二叉树三种遍历方式的递归与非递归实现
- eclipse 导入mvn 项目 阻塞 installing dynamic web module facet
- hdu-1013 Digital Roots
- 对RecyclerView的item添加点击事件