GitHub入門教程

前言:這個是官方教程,看完覺得寫的挺淺顯易懂的,于是翻譯一下給需要的人,本人才疏學(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!
:octocat:
:octocat:

通過完成這個教程,你已經(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

:octocat:
:octocat:

如果你想學(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/

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末嗤谚,一起剝皮案震驚了整個濱河市氢哮,隨后出現(xiàn)的幾起案子育拨,更是在濱河造成了極大的恐慌,老刑警劉巖肝断,帶你破解...
    沈念sama閱讀 216,496評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異捉超,居然都是意外死亡府适,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,407評論 3 392
  • 文/潘曉璐 我一進(jìn)店門佣盒,熙熙樓的掌柜王于貴愁眉苦臉地迎上來挎袜,“玉大人,你說我怎么就攤上這事肥惭《⒁牵” “怎么了?”我有些...
    開封第一講書人閱讀 162,632評論 0 353
  • 文/不壞的土叔 我叫張陵蜜葱,是天一觀的道長全景。 經(jīng)常有香客問我,道長笼沥,這世上最難降的妖魔是什么蚪燕? 我笑而不...
    開封第一講書人閱讀 58,180評論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮奔浅,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘诗良。我一直安慰自己汹桦,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,198評論 6 388
  • 文/花漫 我一把揭開白布鉴裹。 她就那樣靜靜地躺著舞骆,像睡著了一般。 火紅的嫁衣襯著肌膚如雪径荔。 梳的紋絲不亂的頭發(fā)上督禽,一...
    開封第一講書人閱讀 51,165評論 1 299
  • 那天,我揣著相機(jī)與錄音总处,去河邊找鬼狈惫。 笑死,一個胖子當(dāng)著我的面吹牛鹦马,可吹牛的內(nèi)容都是我干的胧谈。 我是一名探鬼主播忆肾,決...
    沈念sama閱讀 40,052評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼菱肖!你這毒婦竟也來了客冈?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,910評論 0 274
  • 序言:老撾萬榮一對情侶失蹤稳强,失蹤者是張志新(化名)和其女友劉穎场仲,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體退疫,經(jīng)...
    沈念sama閱讀 45,324評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡渠缕,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,542評論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了蹄咖。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片褐健。...
    茶點故事閱讀 39,711評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖澜汤,靈堂內(nèi)的尸體忽然破棺而出蚜迅,到底是詐尸還是另有隱情,我是刑警寧澤俊抵,帶...
    沈念sama閱讀 35,424評論 5 343
  • 正文 年R本政府宣布谁不,位于F島的核電站,受9級特大地震影響徽诲,放射性物質(zhì)發(fā)生泄漏刹帕。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,017評論 3 326
  • 文/蒙蒙 一谎替、第九天 我趴在偏房一處隱蔽的房頂上張望偷溺。 院中可真熱鬧,春花似錦钱贯、人聲如沸挫掏。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,668評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽尉共。三九已至,卻和暖如春弃锐,著一層夾襖步出監(jiān)牢的瞬間袄友,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,823評論 1 269
  • 我被黑心中介騙來泰國打工霹菊, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留剧蚣,地道東北人。 一個月前我還...
    沈念sama閱讀 47,722評論 2 368
  • 正文 我出身青樓,卻偏偏與公主長得像券敌,于是被迫代替她去往敵國和親唾戚。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,611評論 2 353

推薦閱讀更多精彩內(nèi)容