GitHub入门教程

前言:这个是官方教程,看完觉得写的挺浅显易懂的,于是翻译一下给需要的人,本人才疏学浅,有翻译的不到位的地方欢迎指正.

Intro 1.简介
What is GitHub? 2.什么是github?
Create a Repository 3.创建一个库
Create a Branch 4.创建一个分支
Make a Commit 5.做一次提交
Open a Pull Request 6.提出一次Pull Request
Merge Pull Request 7.合并Pull Request

The Hello World project is a time-honored tradition in computer programming. It is a simple exercise that gets you started when learning something new. Let’s getstarted with GitHub!
在计算机编程领域,每当学习一个新的东西的时候,开始都会创建一个HelloWorld工程,这是一个历史悠久的传统,那么,就让我们也通过HelloWorld开始我们的GitHub之旅吧!

You’ll learn how to:

你将学会如何:

  • Create and use a repository
  • 创建并使用一个库
  • Start and manage a new branch
  • 开始并管理一个新的分支
  • Make changes to a file and push them to GitHub as commits
  • 修改一个文件并把这项修改上传到GitHub
  • Open and merge a pull request
  • 打开并合并一次Pull Request

What is GitHub?**

什么是GitHub**

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.This tutorial teaches you GitHub essentials like repositories, branches, commits, and Pull Requests. You’ll create your own Hello World repository and learn GitHub’s Pull Request workflow, a popular way to create and review code.

GitHub是一个非常方便进行版本控制和联合开发的代码托寄平台.这个教程将会教你几个关于GitHub的要点,像库,分支,更新和Pull Request.你将会创建你自己的HelloWorld库并且学会GitHubPull Request的工作流程,对创建和回顾代码来说,这将非常方便,这种代码管理方式很受欢迎.

No coding necessary

不需要写代码

To complete this tutorial, you need a GitHub.com account and Internet access. You don’t need to know how to code, use the command line, or install Git (the version control software GitHub is built on).

为了完成这个教程,你仅仅需要一个GitHub账户和一台能上网的电脑.你不需要知道如何写控制Git的代码,使用命令行程序或者安装Git(GitHub的版本控制软件)

Tip: Open this guide in a separate browser window (or tab) so you can see it while you complete the steps in the tutorial.

提醒:你可以把这个教程和GitHub的其他网页以不同的窗口或标签打开来更方便的查看

Step 1. Create a Repository

第一步.创建一个库

A repository is usually used to organize a single project. Repositories can contain folders and files, images, videos, spreadsheets, and data sets –anything your project needs. We recommend including a README, or a file with information about your project. GitHub makes it easy to add one at the same time you create your new repository. It also offers other common options such as a license file.Your **hello-world **repository can be a place where you store ideas, resources, or even share and discuss things with others.

库是用来存放和管理一个单独项目的地方.库里面可以包括文件夹和文件,图片,视频,电子表格和数据组---任何你项目需要的东西.我们建议你的项目里面一定要包括一个readme或者说一个包含关于项目信息的文件.GitHub会在你创建一个新的库的时候提供创建这个readme文件的选项,这非常方便,同时GitHub也提供了例如许可协议文件的其他选项.你的HelloWorld库是一个可以存放想法 资源甚至是一个和其他人分享和讨论事情的地方.

To create a new repository
创建一个新的库
  • In the upper right corner, next to your avatar or identicon, click and then select New repository.
  • 1.在右上角,点击加号选择New repository.
  • Name your repository hello-world.
  • 2.给库命名hello-world
  • Write a short description.
  • 3.写一下这个库的简要说明
  • Select Initialize this repository with a README.
  • 4.选择生成一个带README的库


Click Create repository.
点击Create repository按钮.

Step 2. Create a Branch

第二步.创建一个分支

Branching is the way to work on different versions of a repository at one time.By default your repository has one branch named master which is considered to be the definitive branch. We use branches to experiment and make edits before committing them to master When you create a branch off the master branch, you’re making a copy, or snapshot, of master as it was at that point in time. If someone else made changes to the master branch while you were working on your branch, you could pull in those updates.
分支是一种可以同时在不同版本上工作的方法.默认情况下你新建的库里面会有一个叫做master的分支,在和master分支融合之前,我们通过创建其他分支来试验和修改项目内容.当你创建一个不同于master的新的分支时,就相当于把你的master分支项目复制了一份,当有人更改这个项目时,你可以选择把这些更改作为更新加入到你的master分支项目里.

This diagram shows:
下面的这个图展示的是:
  • The master branch
  • master分支
  • A new branch called feature (because we’re doing ‘feature work’ on this branch)
  • 一个叫做feature的新的分支(因为在这个分支上做的是不一样的工作)
  • The journey that feature takes before it’s merged into master
  • 这就是feature分支被合并到master分支的过程

Have you ever saved different versions of a file? Something like:
你是否见过一个文件的不同版本呢?例如:
story.txt
story-joe-edit.txt
story-joe-edit-reviewed.txt

Branches accomplish similar goals in GitHub repositories.
在一个库空,不同的分支其实是为了完成同一个目标.
Here at GitHub, our developers, writers, and designers use branches for keeping bug fixes and feature work separate from our master
(production) branch. When a change is ready, they merge
在GitHub,我们开发者,作家和设计师通过使用来自master的不同分支来修补bug和完成各自不同的工作. 当更新完成后,他们把这些不同的分支合并到master分支里.
their branch into master
.

To create a new branch
创建一个新的分支
  • Go to your new repository hello-world
  • 1.去HelloWorld所在的库.
  • Click the drop down at the top of the file list that says branch: master.
  • 2.点击branch按钮中的下拉菜单中的master.
  • Type a branch name, readme-edits , into the new branch text box.
  • 3.在输入框中输入一个新的branch名字: readme-edits,
  • Select the blue Create branch box or hit “Enter” on your keyboard.
  • 4.点击蓝色的Create Branch按钮或者按下Enter键.

Now you have two branches, master
and readme-edits
. They look exactly the same, but not for long! Next we’ll add our changes to the new branch.
现在你有了两个分支,master和readme-edits.他们几乎一样,但是不会很久.接下来我们就要在新的分支里加入改动.

Step 3. Make and commit changes

第三步.提交一次更改

Bravo! Now, you’re on the code view for your readme-edits
branch, which is a copy of master
. Let’s make some edits.
好极了!现在,你看到的是readme-edits分支里的代码,这个代码是master分支的复制版.让我们做一些更改.
On GitHub, saved changes are called commits. Each commit has an associatedcommit message, which is a description explaining why a particular change was made. Commit messages capture
在GitHub上,保存改动被称为commits.每个commit都会有一个关联的commit信息,commit信息用来记录每次更改的内容,通过这个信息其他人能够明白你做了什么,为什么做.
the history of your changes, so other contributors can understand what you’ve done and why.

Make and commit changes
提交一次更改
Click the README.md
file.1. 点击 README.md文件
Click the pencil icon in the upper right corner of the file view to edit.2.为了编辑,点击文件右上角的钢笔图标
In the editor, write a bit about yourself.3.在编辑器里,写一些关于你的事.
Write a commit message that describes your changes.4.写一个commit说明来说明你的改动.
Click Commit changes button.5.点击Commit changes按钮.


These changes will be made to just the README file on your readme-edits
branch, so now this branch contains content that’s different from master
.
这下在你已经在你的readme-edits的分支里做出了改动,因此现在这个分支里已经包含着与master分支不同的内容了.

Step 4. Open a Pull Request

第四步.发起一个Pull Request

Nice edits! Now that you have changes in a branch off of master
, you can open a pull request.
改的好,现在你已经对做了不同于master的改动,你可以发起Pull Request了.
Pull Requests are the heart of collaboration on GitHub. When you open a pull request, you’re proposing your changes and requesting that someone review and pull in your contribution and
在GitHub上,Pull Requests是协同合作的核心,当你发起一次Pull request时,你是在提出你的改动,是在请求别人检查你的工作成果并把这些成果合并到他的分支中.
merge them into their branch. Pull requests showdiffs, or differences, of the content from both branches. The changes, additions, and subtractions are shown in green and red.
Pull requests 代表的不同分支的不同之处, 绿色和红色代表着不同的含义,如:更改内容/增加内容/减少内容.
As soon as you make a commit, you can open a pull request and start a discussion, even before the code is finished.
每当你有所改动,你都可以发起一次pull request,甚至在你完成代码之前.
By using GitHub’s @mention system in your pull request message, you can ask for feedback from specific people or teams, whether they’re down the hall or 10 time zones away.
通过在你的pull request信息中使用GitHub的@mention system ,你可以从一个特定的人或团队那里请求反馈,不论他们离你有多远.
You can even open pull requests in your own repository and merge them yourself. It’s a great way to learn the GitHub Flow before working on larger projects.
你甚至可以在你自己的库里发起pull reque并合并到你的项目里.在开始一个大项目之前,了解GitHub的这个工作流程真的非常重要.

Open a Pull Request for changes to the README
对README发起一个pull request
Click on the image for a larger version
点击图片放大
Click the Pull Request tab, then from the Pull Request page, click the green New pull request button.
点击Pull Request 标签,然后在pull request页中点击 绿色的**New pull request **按钮.

Select the branch you made,readme-edits
, to compare with master
(the original).
选择你更改过的readme-edits分支来和master分支进行比较.


Look over your changes in the diffs on the Compare page, make sure they’re what you want to submit.

When you’re satisfied that these are the changes you want to submit, click the big green Create Pull Requestbutton.
当你对这些所做的更改满意并想要提交的话,点击那个大大的Create Pull Request按钮.

Give your pull request a title and write a brief description of your changes.
给你的pull request起一个名字并写一个简单的描述

When you’re done with your message, click Create pull request!
当你完成后,点击 Create pull request!
Tip: You can use emoji and drag and drop images and gifs onto comments and Pull Requests.
提示:在pull request信息中,你可以用表情符号或拖拽图片进去.

Step 5. Merge your Pull Request

第五步.合并你的Pull Request

In this final step, it’s time to bring your changes together – merging yourreadme-edits
branch into the master
branch.
最后一步了,现在是时候把你的改动合并了,把你的readme-edits分支合并到master分支里.
Click the green Merge pull request button to merge the changes intomaster. 1
.点击绿色的Merge pull request 按钮来把改动合并到master里.
Click Confirm merge.2.点击
Confirm merge
按钮.
Go ahead and delete the branch, since its changes have been incorporated, with the Delete branch button in the purple box.

 3.现在你可以把这个分支删掉了,因为它的改动已经被合并到master里面了,删除按钮是 **Delete branch**,在一个紫色的框里.


Celebrate!
庆祝吧!
By completing this tutorial, you’ve learned to create a project and make a pull request on GitHub!
:octocat:
:octocat:

通过完成这个教程,你已经学会如何在GitHub上创建一个项目并发起一个pull request!
Here’s what you accomplished in this tutorial:
下面是你通过这个教程学会的技能
Created an open source repository
创建一个开源库
Started and managed a new branch
开始并管理一个新的分支
Changed a file and committed those changes to GitHub
改动一个文件并把这些改动更新到GitHub上.
Opened and merged a Pull Request.
发起并合并一个Pull Request.

Take a look at your GitHub profile and you’ll see your new contribution squares!
看一下你的GitHub文件,你会发现你的贡献正方形.(绿色或红色的正方形)
If you want to learn more about the power of Pull Requests, we recommend reading the GitHub Flow Guide. You might also visit GitHub Explore and get involved in an Open Source project

:octocat:
:octocat:

如果你想学习更多关于pull request的内容,我们推荐阅读 GitHub Flow Guide. 你还可以通过访问GitHub Explore来参与到一个开源项目中去.再见.
Tip: Check out our other Guides and YouTube Channel for more GitHub how-tos.
提示:查看我们的其他的指导和Youtube频道来学习更多的教程.

结语:我的博客:http://www.cnblogs.com/qiaogaojian/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,332评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,508评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,812评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,607评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,728评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,919评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,071评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,802评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,256评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,576评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,712评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,389评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,032评论 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,798评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,026评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,473评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,606评论 2 350

推荐阅读更多精彩内容