1. 程式人生 > >Git及Github(Odoo程式碼所在平臺)官方入門教程翻譯:Learn Git and GitHub without

Git及Github(Odoo程式碼所在平臺)官方入門教程翻譯:Learn Git and GitHub without



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 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(引入請求)。您將建立您的Hello World倉庫以及學習GitHub的pull request流程,這是一種流行的方式來建立和檢閱程式碼。

No coding necessary無需程式設計

To complete this tutorial,you need aGitHub.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建立一個新的倉庫

In the upper right corner,next to your username,click and then click New repository.在螢幕右上角,您使用者名稱之前,點選+號,並點選New repository(新建倉庫).

Name your repository hello-world.給您的新倉庫命名為hello-world

Write a short description.寫一份簡短的描述。

Select Initialize this repository with a README.勾選初始化倉庫包含一個README自述檔案。

Click Create repository.點選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前的行程

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建立一個新的分支

Go to your new repository hello-world.進入到您的倉庫hello-world.

Click the drop down at the top of the file list that says branch:master.點選頂部的檔案列表:master

Type a branch name,readme-edits,into the new branch text box.輸入分支名稱,readme-edits到新的分支的文字輸入區

Select the blue Create branch box or hit“Enter”on your keyboard.選擇藍色的Create branch或者回車。

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做出更改並提交

Click the README.md file.點選README.md檔案

Click the pencil icon in the upper right corner of the file view to edit.點選右上角的鉛筆圖示來編輯滑鼠停留在這個圖示上時會出現Edit this file的提示

In the editor,write a bit about yourself.在編輯器中,寫下一些介紹您自己的內容。

Write a commit message that describes your changes.寫下提交資訊描述您的改動。

Click Commit changes button.點選Commit changes按鈕。

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按鈕.

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

3:Look over your changes in the diffs on the Compare page,make sure they’re what you want to submit.在對比頁面檢視您的更改,確認他們是您想提交的。

4:When you’re satisfied that these are the changes you want to submit,click the big greenCreate Pull Requestbutton.當您對這些改動滿意後,點選綠色的Create Pull Request按鈕。

5:Give your pull request a title and write a brief description of your changes.給您的此次提交合並一個標題,並對更改作出簡短的描述

When you’re done with your message,click Create pull request!當您完成了這些資訊之後,點選Create pull request!

Tip:You can useemoji

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

Click the green Merge pull request button to merge the changes intomaster.點選綠色的Merge pull request按鈕來合併更改到master分支。

Click Confirm merge.點選Confire merge.

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

Celebrate!慶祝!

By completing this tutorial,you’ve learned to create a project and make a pull request on GitHub!通過完成這個課程,您學習瞭如何建立一個專案以及在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 newcontribution squares

!看看您在GitHub中的your profile配置檔案,會看到您的貢獻!

If you want to learn more about the power of pull requests,we recommend reading theGitHub Flow Guide

.You might also visitGitHub Explore

and get involved in an Open Source project

如果您想了解更多關於pull requests的知識,我們建議您閱讀GitHub Flow Guide

.您還可以瀏覽GitHub Explore

參與一個開源專案。

Tip:Check out our otherGuides

andYouTube Channel

for more GitHub how-tos.

提示:閱覽我們其他手冊

YouTube頻道

獲得更多的GitHub how-tos.

Git和GitHub的其他中文資料還可參考:

和:http://www.linuxidc.com/Linux/2011-04/35036.htm

以及:https://www.zhihu.com/question/21682976

以上,算是一個瞭解下如何使用GitHub的版本控制的入門教程,

整篇課程相對直觀,沒打任何命令,應該能讓讀者加深理解repository,branch,commit,Pull Request這些術語。

我們保留了英文原文,在世界日趨扁平化的今天,方便大家學習英語,更是為了方便大家提出修改意見和建議。

謝謝大家。