打開你的開源社區GitHub之路 GitHub Guide 中文翻譯全文

2021-02-20 經濟學人與專業英語精讀賞析

寫在前面:近來作者正在學習nodejs開發公眾平臺,因為nodejs的源碼在GitHub上面,所以順便學習了GitHub如何使用。因為教程上全是英文,一些小夥伴閱讀起來有點困難,因此在這裡為大家翻譯一下。不是計算機專業的同學也可以讀一讀,了解一下你身邊程式設計師同學的日常,說不定你以後就嫁(娶)了一個程式設計師呢:}

那麼首先,什麼是GitHub呢?

知乎上看到一個網友提了一個關於GitHub的問題,得到了一個神一般存在的有趣回答。

GitHub 是怎樣的一個存在?
1.求職時候發現有些公司要附GitHub帳號;
2.自己竟然沒聽說過;
3.怎樣用好GitHub,他可以幫我做什麼;

Johnny Wu 神一般的回答到:
1.求職時候發現有些公司要附Github帳號

該公司的員工應該有強烈的同性交友傾向, 並且希望能夠記錄下每一個面試的同性開發人員的交友帳號, 作為公司福利在公司內傳閱.

2.自己竟然沒聽說過

同性交友圈的暗號很多, 很難一開始就介入, 但是只要有志氣, 有心一定能夠在網絡中的蛛絲馬跡中找到, 並發掘出身邊的同性工作者.

3.怎樣用好Github,他可以幫我做什麼

和普通朋友圈一樣, 你需要不斷的提交自己的日常, 普通朋友圈一般提供自己的心情短語, 自拍生活照. Github 上, 同性之間的交流通過暗號, 暗語. 所以提交自己的生活日常時, 請進行對應的暗語處理. 他可以幫助你找到志同道合的同志. I can feel your love when you git pull-and-push to the Hub.

然而百度百科給出的結果是:

GitHub 是一個面向開源及私有軟體項目的託管平臺,因為只支持 Git 作為唯一的版本庫格式進行託管,故名 GitHub。

GitHub 於 2008 年 4 月 10 日正式上線,除了 Git 代碼倉庫託管及基本的 Web 管理界面以外,還提供了訂閱、討論組、文本渲染、在線文件編輯器、協作圖譜(報表)、代碼片段分享(Gist)等功能。目前,其註冊用戶已經超過350萬,託管版本數量也是非常之多,其中不乏知名開源項目 Ruby on Rails、jQuery、python 等。

接下來我們開啟正文,看看官方給出的使用教程,注意使用教程之前要註冊帳戶哦!

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項目在計算機編程中是一個歷史悠久的傳統。這個簡單的練習可以幫助你開始學習一些新東西。讓我們從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

Open and merge a pull request

你將會學習到:

(因為repository,branch, commit, pull request找不到特別準確的翻譯,同時以後會經常見到他們,所以下文就不翻譯這些單詞了)

What is 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是一個代碼版本控制和合作的託管平臺。它可以讓你和來自任何地方的其他人共同完成程序項目。

這份教程將會教你GitHub上的必需品,比如repositories,branches, commits 和Pull Requests。 你將創建你自己的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).

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帳戶並聯網。你不需要直到怎樣寫代碼,使用命令行或者安裝Git(GitHub在其上建立的版本控制軟體)。

Tip:用一個不同的瀏覽器(或者標籤)這樣你就可以邊看邊完成教程了。

Step 1. Create a Repository

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.

步驟1.建立一個Repository

一個repository通常用於組織一個獨立的程序。Repository可以包含任何你程序需要的文件夾或文件,圖片,視頻,電子數據表和數據集。我們建議包括一個README文件,或者一個包含你程序信息的文件。GitHub使你在創建新的repository的同時很容易去添加一個。它同時提供其他常見選項,比如一個許可文件。

你的hello-world repository 可以用於你存儲想法,資源或者甚至和其他人分享和討論事物。

To create a new repository

In the upper right corner, next to your avatar or identicon, click  and then select New repository.

Name your repository hello-world.

Write a short description.

Select Initialize this repository with a README.

創建一個新 repository

在右上角,挨著你的圖標頭像或者是哈希圖像(新註冊時沒有上傳頭像,系統使用哈希算法給你生成的那個頭像),點擊+然後選擇New repository

為它起名hello-world.

寫一個短的描述.

選擇帶著一個README文件初始化這個repository。

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.

步驟2.創建一個Branch

Branching是一種同時工作在不同版本repository上的方法

默認狀態下你的repository有一個master 分支被認作權威分支。 在提交給master之前我們使用其他分支去實驗和修改。

當你從master分支上創建一個分支,從那時起你就創建了一個master副本,或者說快照。如果其他人在你使用你的分支時在master上做了改變,你也可以獲得那些更新。

This diagram shows:

這張示意圖展示了:

Have you ever saved different versions of a file? Something like:

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

你曾經把一個文件保存成很多版本過嗎?就像這樣

在GitHub repository中,分支實現的就是相似的目標。

在GitHub,我們的開發者,寫者,和設計師使用分支去修復bug並在master(產品)的不同分支上做一些重要的工作。當一個改變準備好了,他們就把他們的分支合併到master上When a change is ready, they merge their branch into master.

To create a new branch

Go to your new repository hello-world.

Click the drop down at the top of the file list that says branch: master.

Type a branch name, readme-edits, into the new branch text box.

Select the blue Create branch box or hit 「Enter」 on your keyboard.

怎樣去創建一個新的分支

來到你的新repository hello-world中。

點擊文件列表最上方那個的下拉項, branch: master。

在新分支編輯框中輸入一個分支名,readme-edits.

選擇藍色.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.

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 the history of your changes, so other contributors can understand what you』ve done and why.

步驟3.改動並提交

厲害了,我的哥!現在你就已經在你的readme-edits分支(master分支的副本)代碼視圖中了。來讓我們做些編輯。

在GitHub上,保存改變叫做commits(提交)。 每份提交都有一個相關聯的提交信息,它描述解釋了為什麼要做出這個特定改變。提交信息捕獲你改動的歷史,這樣其他合作者就能明白你做了什麼,有什麼目的。

Make and commit changes

Click the README.md file.

Click the  pencil icon in the upper right corner of the file view to edit.

In the editor, write a bit about yourself.

Write a commit message that describes your changes.

Click Commit changes button.

製作和提交改變

點擊README.md文件。

點擊文件視圖右上角的鉛筆按鈕來編輯。

在編輯器中寫點關於你自己的東西。

寫一個提交信息來描述你的修改。

點擊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分支中生效,所以現在這個分支包含的內容已經和master不同了。

Step 4. Open a Pull Request

Nice edits! Now that you have changes in a branch off of master, you can open a 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.

步驟4.開啟一個Pull Request(提取請求)

很棒的編輯!既然你在master分離出的分支中做了修改,你就可以開啟一個pull request了

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.

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.

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 request並開始討論,即使在你的代碼還沒完成。

在你的pull request消息中,通過使用GitHub的@mention system,你可以想特定的人或團體請求反饋,無論他們實在下面的大廳還是相隔10個時區的地方。

你甚至可以在你自己的repository中開啟pull request並合併他們。這是在你製作大型工程前學習GitHub的好方法。

Open a Pull Request for changes to the README

Click on the image for a larger version

When you’re done with your message, click Create pull request!

Tip: You can use emoji and drag and drop images and gifs onto comments and Pull Requests.


開啟對README改動的pull request

點擊圖片獲取大圖

當你完成了你的信息,點擊 Create pull request!

Tip:你可以在評論區和Pull reque區使用emoji表情,拖拽圖片和動態圖。

Step 5. Merge your Pull Request

In this final step, it’s time to bring your changes together – merging yourreadme-edits branch into the master branch.

Click the green Merge pull request button to merge the changes intomaster.

Click Confirm merge.

Go ahead and delete the branch, since its changes have been incorporated, with the Delete branch button in the purple box.

步驟5.合併你的Pull Request

在最後一步。是時候把你的改動融合到一起了,也就是把read-me分支和master分支合併到一起。

點擊綠色按鈕Merge pull request 將改動合併到master。

點擊Confirm merge。

繼續並按紫色框中的Delete branch刪除分支,因為這些改動已經合併完成了。

Celebrate!

By completing this tutorial, you』ve learned to create a project and make a pull request on GitHub!  

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

Opened and merged a Pull Request

Take a look at your GitHub profile and you』ll see your new contribution squares!

To learn more about the power of Pull Requests, we recommend reading theGitHub Flow Guide. You might also visit GitHub Explore and get involved in an Open Source project 

Tip: Check out our other Guides, YouTube Channel and On-Demand Training for more on how to get started with GitHub.

祝賀你!

完成了這個教程,你已經學會了在GitHub上創建工程和製作pull request。

這裡是你在此教程中完成的東西:

創建和打開源倉庫。

打開和管理一個新分支。

改動一個文件並把這些改動提交給GitHub。

打開和合併一個pull request。

看看你的GItHub配置文件,你會看到你的新貢獻方塊!

要更深入了解Pull Request的能力,我們推薦去讀GitHub Flow Guide。你也可以訪問GitHub Explore 並參加一個開源項目。

P.S.如果覺得本文以後對你有用的話(不管是寫代碼還是同性交友)記得點擊收藏,方便以後使用哦~另外點擊閱讀全文可以進入GitHub網站閱讀原文。

相關焦點

  • Github最值一讀開源好書及BAT面試題庫
    (Github開源地址:http://pythonguidecn.readthedocs.io/zh/latest/)3、《國內一線網際網路公司內部面試題庫》該開源項目在Github上已有6000多Star,主要是來自國內一線網際網路公司的面試題集錦,涉及Java和Android兩大方向,涉及的公司有百度、小米、美團、58、獵豹、360、新浪、搜狐等。
  • Rustc Dev Guide 中文翻譯啟動
    Rust編譯器開發指南(Rustc Dev Guide) 的中文翻譯已經啟動
  • 10月份Github上熱門的開源項目
    10月份GitHub上最熱門的Java開源項目排行已經出爐啦,一起來看看上榜詳情吧:1. base-adminhttps://github.com/huanzi-qch/base-adminStar 1499Base Admin一套簡單通用的後臺管理系統
  • 2019年第一季度GitHub上最熱門的開源項目
    https://github.com/kamranahmedse/developer-roadmap Star 709202019年Web開發人員的路線圖,這組圖表是為了讓你更直觀的了解到,如果你要成為一個前端、後端或DevOps開發者需要具備哪些技術能力,並逐漸深入了解哪個工具才是最適合你的https://github.com/alexkimxyz/nsfw_data_scrapper
  • 1月份Github上熱門Python開源項目!
    SpiderFoot是一個免費的、開源的網站信息收集工具,你可以根據指定域名獲得信息,如網站子域、電子郵件地址、web伺服器版本等等,可以幫助滲透測試人員自動化的實現網站信息收集、資產發現的過程,提高工作效率。
  • GitHub官方開源新命令行工具
    現在,你就可以在macOS、Windows和Linux上安裝GitHub CLI。Github也會通過用戶反饋,在之後的版本中添加更多的功能。GitHub CLI現在提供了一些開源貢獻者會使用的基本功能,從問題(Issue)以及拉取請求(Pull Request)開始。
  • GitHub開源中文版《Go入門指南》學習教程
    ▍Go入門指南最近,boy哥逛GitHub發現了一個學習 Go 語言的寶藏資源《Go 入門指南》,它是英文書《The Way to Go》的中文翻譯版,作者名字為 unknwon,下面使他自己的感悟。但由於目前國內並沒有比較好的 Go 語言書籍,而國外的優秀書籍因為英文的緣故在一定程度上也為不少 Go 語言愛好者帶來了一些學習上的困擾,不僅為了加快擴散 Go 愛好者的國內群體,本人在完成閱讀這本名叫 《The Way to Go》 之後,決定每天抽出一點時間來進行翻譯的工作,並且以開源的形式免費分享給有需要的 Go 語言愛好者。
  • GitHub 中文排行榜
    今天在看 GitHub 的時候,看到了這個「GitHub 中文排行榜」的開源項目,裡面質量很高,是幫助大家發現高分的優秀的「中文項目」。 通過裡面收集的優質的高分開源項目大家可以更高效地吸收國人的優秀經驗、成果。所謂:站在巨人的肩膀上,我們才能看的更高和更遠嘛!
  • GitHub中文幫助文檔上線:統一術語翻譯,Fork成「分叉」
    GitHub剛剛推出官方中文幫助文檔,這是繼日文版之後第二個非英語語種的幫助文檔。GitHub希望藉此能夠幫助中文開發者更好的理解GitHub操作規範,降低學習門檻。曾經,為了能暢通的瀏覽/使用GitHub而努力學習英語;現在,那股動力眼看就要被澆滅了。
  • 8月份GitHub上熱門的Java開源項目
    8月份GitHub上最熱門的Java開源項目排行已經出爐啦,一起來看看上榜詳情吧:5834tsunami-security-scanner是谷歌專門為大型企業網絡開源的一個漏洞掃描神器,主要用於數千個甚至數百萬個物聯網組成的企業系統。
  • 200+優秀Github項目精選
    第三方庫/開源項目fxsjy / jieba結巴中文分詞。lancopku / pkuseg-pythonpkuseg多領域中文分詞工具。hollischuang / toBeTopJavaerTo Be Top Javaer - Java工程師成神之路。
  • GitHub 上的十一款熱門開源安全工具 - OSCHINA - 中文開源技術...
    GitHub上的十一款熱門開源安全工具作為開源開發領域的基石,「所有漏洞皆屬淺表」已經成為一條著名的原則甚至是信條。作為廣為人知的Linus定律,當討論開源模式在安全方面的優勢時,開放代碼能夠提高項目漏洞檢測效率的理論也被IT專業人士們所普遍接受。現在,隨著GitHub等高人氣代碼共享站點的相繼湧現,整個開源行業開始越來越多地幫助其它企業保護自己的代碼與系統,並為其提供多種多樣的安全工具與框架,旨在完成惡意軟體分析、滲透測試、計算機取證以及其它同類任務。
  • GitHub 徽章製作
    讓你的開源項目更高大上, 讓你的代碼也更健壯.徽章的含意當你瀏覽一個開源項目時,看到各種徽章, 有些徽章是直接反應這個開源庫的質量和完整性等等.持續集成和持續部署目前 github 官方自帶支持, 官方稱之為 GitHub Actions.只要你在 github 上創建一個開源項目倉庫就自帶 Actions 功能, 支持各種語言. 還可以自動發布 GitHub Pages 等功能, 十分強大.
  • GitHub開源項目2018-10-31更新精選
    https://github.com https://github.com https://github.com/knowm/XChart 4.一個非常簡單的 BiLSTM-CRF 模型用於中文命名實體識別 (TensorFlow)一個非常簡單的 BiLSTM-CRF 模型用於中文命名實體識別 (TensorFlow)
  • 2018年11月份GitHub上最熱門的開源項目
    >連結:https://www.itcodemonkey.com/article/11806.html本篇文章為大家盤點了11月份最熱門的GitHub 項目,一起來看看你都知道哪些,或者有哪些你已經在使用的了。
  • 終於Github App支持中文簡體了!
    Github作為網際網路上最大的開源社區,一直備受程式設計師的喜愛,裡面不僅有許多優秀的開源項目,其中不乏知名開源項目 Ruby on Rails、jQuery、python。去年11月,GitHub首次宣布推出手機APP,並開始在iOS和Android進行Beta測試。
  • GitHub開源新命令行工具:在終端裡創建、管理PR成現實
    更快的 gh 已經引起了社區的共鳴。目前,上線的 GitHub CLI 還只是測試版本,GitHub 官方表示,期待來自你的使用反饋~macOS,Windows 和 Linux 均可安裝。根據需求過濾舉個例子,在你看中了一個開源項目,並希望為其貢獻智慧,可以使用這樣的命令行:gh issue list - -label 「help wanted」這樣,帶有「help wanted」標籤的 issue
  • 這個超輕量中文OCR開源項目在Github火了
    光學字符識別(OCR)相信大家都不陌生,就是指電子設備(例如掃描儀或數位相機)檢查紙上列印的字符,通過檢測暗、亮的模式確定其形狀,然後用字符識別方法將形狀翻譯成計算機文字的過程
  • 8月份GitHub上最熱門的Java項目
    它可以幫助你加快開發進程,有效防止一些可能導致重大失誤的細節問題,不過深入了解 java-design-patterns 之前,你應提前熟悉各種編程/軟體設計原則。https://github.com/proxyee-down-org/proxyee-down Star 13918
  • Github Flow入門指南.
    事實上已經成為了世界上最大的代碼存放網站和開源社區。所以,如果你想要給開源項目貢獻代碼或者翻譯文檔,學會如何使用 GitHub 來正確地貢獻代碼是必不可少的。打開示例倉庫的 URL,在右上角點擊 Fork 按鈕後,開始等待完成。