卓忆翻译:中英对照:Git及Github(Odoo代码所在平台)官方入门教程翻译:Learn Git and GitHub without any code!

2016/03/2020:27:46卓忆翻译:中英对照:Git及Github(Odoo代码所在平台)官方入门教程翻译:Learn Git and GitHub without any code!已关闭评论 3,491 views

卓忆翻译:中英对照:GitGithub(Odoo代码所在平台)官方入门教程翻译

Odoo代码https://www.github.com/odoo,Odoo官方的源代码也托管在GitHub

Learn Git and GitHub without any code无需任何代码,学习Git和GitHub
Using the Hello World guide, you’ll create a repository, start a branch,
write comments, and open a pull request.
使用"Hello World你好世界"手册,您将创建一个仓库,开始一个分支,编写注释,以及打开一个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 get started with GitHub!

"Hello World你好世界"是一个在计算机编程界有着悠久传统的项目。它让您进行这个简单的实践从而开始学习一些新东西。让我们也开始吧!

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 repositoriesbranchescommits, 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(引入请求)。您将创建您的Hello World仓库以及学习GitHub的pull 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.com账户。您无需知道如何编程,以及使用命令行,或安装Git(作为一个版本控制软件Github内置了Git)

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

提示:您可以将教程作为一个标签页分开打开在浏览器窗口,这样您可以在完成教程的过程中始终看到教程。

Step 1. Create a Repository 步骤1.创建一个仓库

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会在您创建新仓库时提示您创建一个。还会提议您许可证文件。

To create a new repository 创建一个新的仓库

  1. In the upper right corner, next to your username, click  and then click New repository. 在屏幕右上角,您用户名之前,点击+号,并点击New repository(新建仓库).
  2. Name your repository hello-world. 给您的新仓库命名为 hello-world
  3. Write a short description. 写一份简短的描述。
  4. Select Initialize this repository with a README. 勾选初始化仓库包含一个README自述文件。

new-repo-formnew-repo-formnew-repo-form

Click Create repository:tada: 点击 Create repository按钮.

Step 2. Create a Branch 步骤2.创建一个分支

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创建了另一个的分支时,相当于您为当前的mstart分支制作了一份拷贝,或快照。当您工作在您的分支时,如果有些人对master分支进行了一些改动,您可以合并这些更新。

This diagram shows: 下面的图表展示了:

  • The master branch 主分支
  • A new branch called feature (because we’re doing ‘feature work’ on this branch) 名为feature的心分支 (这是因为我们做了'feature work'在这个分支)
  • The journey that feature takes before it’s merged into master  . feature 合并到master前的行程

a branch

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.

分支在GitHub仓库中,完成了类似"版本控制"的目标.

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 their branch into master.

在GitHub我们的开发者,作者,设计师使用分支来修复bug和分工协作。当改动准备好了,他们就合并他们的分支到master.

To create a new branch 创建一个新的分支

  1. Go to your new repository hello-world. 进入到您的仓库 hello-world.
  2. Click the drop down at the top of the file list that says branch: master. 点击顶部的文件列表 :master
  3. Type a branch name, readme-edits, into the new branch text box. 输入分支名称,readme-edits 到新的分支的文本输入区
  4. Select the blue Create branch box or hit “Enter” on your keyboard. 选择蓝色的Create branch 或者回车。

branch gif

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.

现在您有了2个分支,master和readme-edits. 他们目前看上去是一样的,接下来我们会增加变化到新的分支。

Step 3. Make and commit changes 步骤3.做出更改并提交

Bravo! Now, you’re on the code view for your readme-edits branch, which is a copy of master. Let’s make some edits.

On GitHub, saved changes are called commits. Each commit has an associated commit message, which is a description explaining why a particular change was made. Commit messages capture the history of your changes, so other contributors can understand what you’ve done and why.

太棒了!现在您位于您readme-edits分支的代码预览页面,它是master分支的拷贝。让我们做一些编辑。

在GitHub, 保存更改被称为 commits提交。每个提交都有相关联的提交信息,它描述解释了为何要做此更改。提交信息保留了您的更改历史,这样其他的贡献者可以理解您所做的以及为何要这样做。

Make and commit changes 做出更改并提交

  1. Click the README.md file. 点击README.md 文件
  2. Click the  pencil icon in the upper right corner of the file view to edit. 点击右上角的铅笔图标来编辑 鼠标停留在 这个 图标 上 时 会出现 Edit this file的提示
  3. In the editor, write a bit about yourself. 在编辑器中,写下一些介绍您自己的内容。
  4. Write a commit message that describes your changes. 写下提交信息描述您的改动。
  5. Click Commit changes button. 点击 Commit changes 按钮。

commit

These changes will be made to just the README file on your readme-editsbranch, so now this branch contains content that’s different from master. 这些改动会应用于readme-edits分支的README文件,现在这个分支的内容和master分支就有所不同了。

Step 4. Open a Pull Request 步骤4. 打开一个Pull Request

Nice edits! Now that you have changes in a branch off of master, you can open a pull request.

做得漂亮!现在我们可以打开 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 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是GitHub协同工作的核心。当您打开一个pull request,您提交您的更改以及请求,有人审阅并把您的贡献引入、然后合并它们到他们的分支中。Pull request会在每个分支显示其改变之处。更改,增加和减少的部分分别显示为绿色和红色。

As soon as you make a commit, you can open a pull request and start a discussion, even before the code is finished. 当您的代码完成后,您立即可以做出一个commit提交,您可以打开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 ,您可以从某个指定人员或者小组取得回馈 ,不论他们是在客厅或是10小时时差之外。

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 requests在您自己的仓库并合并他们。在为更大的项目工作之前,这是一个很好的学习GitHub工作流的方法。

Open a Pull Request for changes to the README 为更改后的README 打开Pull Request

1: Click the  Pull Request tab, then from the Pull Request page, click the green New pull request button.点击 Pull Request 标签页, 点击绿色的 New pull request 按钮.

pr-tab

2: Select the branch you made,readme-edits, to compare with master (the original).选择您的分支,readme-edits,和 master比较 (原始分支).

branch

 

3:Look over your changes in the diffs on the Compare page, make sure they’re what you want to submit. 在对比页面查看您的更改,确认他们是您想提交的。

diff

 

4:When you’re satisfied that these are the changes you want to submit, click the big greenCreate Pull Requestbutton.  当您对这些改动满意后,点击绿色的Create Pull Request按钮。

create-pull

 

5:Give your pull request a title and write a brief description of your changes. 给您的此次提交合并一个标题,并对更改作出简短的描述

pr-form

 

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 Requests中使用 emoji 和 drag and drop images and gifs

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分支

  1. Click the green Merge pull request button to merge the changes intomaster. 点击绿色的Merge pull request 按钮来合并更改到master分支。
  2. Click Confirm merge. 点击 Confire merge.
  3. Go ahead and delete the branch, since its changes have been incorporated, with the Delete branch button in the purple box. 当改动生效后,使用Delete branch按钮 删除分支readme-edits

mergedelete

Celebrate! 庆祝!

By completing this tutorial, you’ve learned to create a project and make a pull request on GitHub! :tada: :octocat: :zap: 通过完成这个课程,您学习了如何创建一个项目以及在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中的your profile配置文件,会看到您的贡献!

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:

如果您想了解更多关于pull requests的知识,我们建议您阅读 GitHub Flow Guide. 您还可以浏览GitHub Explore 参与一个开源项目。


Tip: Check out our other Guides and YouTube Channel for more GitHub how-tos.

提示:阅览我们其他 手册 和 YouTube 频道  获得更多的GitHub how-tos.

Git 和 GitHub的其他中文资料还可参考:
 以上,算是一个了解下如何使用GitHub的 版本控制 的 入门教程 ,
整篇课程相对直观,没打任何命令,应该能让读者加深理解repository, branch,commit ,Pull Request 这些术语。
我们保留了英文原文,在世界日趋扁平化的今天,方便大家学习英语,更是为了方便大家提出修改意见和建议。

谢谢大家。

                                                                            以上文档及测试耗时3小时,卓忆科技,2016-3-20日