前言:這個是官方教程,看完覺得寫的挺淺顯易懂的,于是翻譯一下給需要的人,本人才疏學(xué)淺,有翻譯的不到位的地方歡迎指正.
Intro 1.簡介
What is GitHub? 2.什么是github?
Create a Repository 3.創(chuàng)建一個庫
Create a Branch 4.創(chuàng)建一個分支
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!
在計算機(jī)編程領(lǐng)域,每當(dāng)學(xué)習(xí)一個新的東西的時候,開始都會創(chuàng)建一個HelloWorld工程,這是一個歷史悠久的傳統(tǒng),那么,就讓我們也通過HelloWorld開始我們的GitHub之旅吧!
You’ll learn how to:
你將學(xué)會如何:
- Create and use a repository
- 創(chuàng)建并使用一個庫
- 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是一個非常方便進(jìn)行版本控制和聯(lián)合開發(fā)的代碼托寄平臺.這個教程將會教你幾個關(guān)于GitHub的要點,像庫,分支,更新和Pull Request.你將會創(chuàng)建你自己的HelloWorld庫并且學(xué)會GitHubPull Request的工作流程,對創(chuàng)建和回顧代碼來說,這將非常方便,這種代碼管理方式很受歡迎.
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賬戶和一臺能上網(wǎng)的電腦.你不需要知道如何寫控制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的其他網(wǎng)頁以不同的窗口或標(biāo)簽打開來更方便的查看
Step 1. Create a Repository
第一步.創(chuàng)建一個庫
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.
庫是用來存放和管理一個單獨項目的地方.庫里面可以包括文件夾和文件,圖片,視頻,電子表格和數(shù)據(jù)組---任何你項目需要的東西.我們建議你的項目里面一定要包括一個readme或者說一個包含關(guān)于項目信息的文件.GitHub會在你創(chuàng)建一個新的庫的時候提供創(chuàng)建這個readme文件的選項,這非常方便,同時GitHub也提供了例如許可協(xié)議文件的其他選項.你的HelloWorld庫是一個可以存放想法 資源甚至是一個和其他人分享和討論事情的地方.
To create a new repository
創(chuàng)建一個新的庫
- 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
第二步.創(chuàng)建一個分支
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.
分支是一種可以同時在不同版本上工作的方法.默認(rèn)情況下你新建的庫里面會有一個叫做master的分支,在和master分支融合之前,我們通過創(chuàng)建其他分支來試驗和修改項目內(nèi)容.當(dāng)你創(chuàng)建一個不同于master的新的分支時,就相當(dāng)于把你的master分支項目復(fù)制了一份,當(dāng)有人更改這個項目時,你可以選擇把這些更改作為更新加入到你的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.
在一個庫空,不同的分支其實是為了完成同一個目標(biāo).
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,我們開發(fā)者,作家和設(shè)計師通過使用來自master的不同分支來修補(bǔ)bug和完成各自不同的工作. 當(dāng)更新完成后,他們把這些不同的分支合并到master分支里.
their branch into master
.
To create a new branch
創(chuàng)建一個新的分支
- 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.點擊藍(lán)色的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.
現(xiàn)在你有了兩個分支,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.
好極了!現(xiàn)在,你看到的是readme-edits分支里的代碼,這個代碼是master分支的復(fù)制版.讓我們做一些更改.
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都會有一個關(guān)聯(lián)的commit信息,commit信息用來記錄每次更改的內(nèi)容,通過這個信息其他人能夠明白你做了什么,為什么做.
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.為了編輯,點擊文件右上角的鋼筆圖標(biāo)
In the editor, write a bit about yourself.3.在編輯器里,寫一些關(guān)于你的事.
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
.
這下在你已經(jīng)在你的readme-edits的分支里做出了改動,因此現(xiàn)在這個分支里已經(jīng)包含著與master分支不同的內(nèi)容了.
Step 4. Open a Pull Request
第四步.發(fā)起一個Pull Request
Nice edits! Now that you have changes in a branch off of master
, you can open a pull request.
改的好,現(xiàn)在你已經(jīng)對做了不同于master的改動,你可以發(fā)起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是協(xié)同合作的核心,當(dāng)你發(fā)起一次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 代表的不同分支的不同之處, 綠色和紅色代表著不同的含義,如:更改內(nèi)容/增加內(nèi)容/減少內(nèi)容.
As soon as you make a commit, you can open a pull request and start a discussion, even before the code is finished.
每當(dāng)你有所改動,你都可以發(fā)起一次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 ,你可以從一個特定的人或團(tuán)隊那里請求反饋,不論他們離你有多遠(yuǎn).
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.
你甚至可以在你自己的庫里發(fā)起pull reque并合并到你的項目里.在開始一個大項目之前,了解GitHub的這個工作流程真的非常重要.
Open a Pull Request for changes to the README
對README發(fā)起一個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 標(biāo)簽,然后在pull request頁中點擊 綠色的**New pull request **按鈕.
Select the branch you made,readme-edits
, to compare with master
(the original).
選擇你更改過的readme-edits分支來和master分支進(jìn)行比較.
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.
當(dāng)你對這些所做的更改滿意并想要提交的話,點擊那個大大的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!
當(dāng)你完成后,點擊 Create pull request!
Tip: You can use emoji and drag and drop images and gifs onto comments and Pull Requests.
提示:在pull request信息中,你可以用表情符號或拖拽圖片進(jìn)去.
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.
最后一步了,現(xiàn)在是時候把你的改動合并了,把你的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.現(xiàn)在你可以把這個分支刪掉了,因為它的改動已經(jīng)被合并到master里面了,刪除按鈕是 **Delete branch**,在一個紫色的框里.
Celebrate!
慶祝吧!
By completing this tutorial, you’ve learned to create a project and make a pull request on GitHub!
通過完成這個教程,你已經(jīng)學(xué)會如何在GitHub上創(chuàng)建一個項目并發(fā)起一個pull request!
Here’s what you accomplished in this tutorial:
下面是你通過這個教程學(xué)會的技能
Created an open source repository
創(chuàng)建一個開源庫
Started and managed a new branch
開始并管理一個新的分支
Changed a file and committed those changes to GitHub
改動一個文件并把這些改動更新到GitHub上.
Opened and merged a Pull Request.
發(fā)起并合并一個Pull Request.
Take a look at your GitHub profile and you’ll see your new contribution squares!
看一下你的GitHub文件,你會發(fā)現(xiàn)你的貢獻(xiàn)正方形.(綠色或紅色的正方形)
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
如果你想學(xué)習(xí)更多關(guān)于pull request的內(nèi)容,我們推薦閱讀 GitHub Flow Guide. 你還可以通過訪問GitHub Explore來參與到一個開源項目中去.再見.
Tip: Check out our other Guides and YouTube Channel for more GitHub how-tos.
提示:查看我們的其他的指導(dǎo)和Youtube頻道來學(xué)習(xí)更多的教程.
結(jié)語:我的博客:http://www.cnblogs.com/qiaogaojian/