Using the Hello World guide, you’ll start a branch, write comments, and open a pull request.git
Read the guidehttps://guides.github.com/activities/hello-world/github
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!編程
You’ll learn how to:瀏覽器
hello world項目是計算機編程中一個由來已久的傳統。這是一個簡單的練習,讓你開始學習新東西。讓咱們從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.ide
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.ui
什麼是Github?
github是一個用於版本控制和協做的代碼託管平臺。它讓你和其餘人在任何地方的項目上一塊兒工做。
本教程將向您介紹GitHub的基本功能,如存儲庫、分支、提交和拉取請求。您將建立本身的hello world存儲庫,並學習github的pull-request工做流,這是一種建立和審查代碼的流行方法。
無需編碼
要完成本教程,您須要github.com賬戶和Internet訪問。您不須要知道如何編寫代碼、使用命令行或安裝git(版本控制軟件github是基於github構建的)。
提示:在單獨的瀏覽器窗口(或選項卡)中打開此指南,以便在完成教程中的步驟時能夠看到它。this
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.
步驟1。建立存儲庫
存儲庫一般用於組織單個項目。存儲庫能夠包含文件夾和文件、圖像、視頻、電子表格和數據集—任何項目須要的內容。咱們建議包括一個自述文件,或者一個包含項目信息的文件。github使您能夠在建立新存儲庫的同時輕鬆添加一個存儲庫。它還提供其餘常見選項,如許可證文件。
hello world存儲庫能夠是一個存儲想法、資源,甚至與他人共享和討論內容的地方。
Great repository names are short and memorable. Need inspiration? How about improved-octo-memory?
偉大的存儲庫名稱是簡短和難忘的。須要靈感嗎?提升octo的記憶力怎麼樣?
Description (optional)
說明(可選)
Anyone can see this repository. You choose who can commit.
任何人均可以看到這個存儲庫。你選擇誰能夠承諾。
You choose who can see and commit to this repository.
您能夠選擇誰能夠查看並提交到此存儲庫。
Skip this step if you’re importing an existing repository.
若是要導入現有存儲庫,請跳過此步驟。
Initialize this repository with a README
使用自述文件初始化此存儲庫
Click Create repository.
單擊建立存儲庫。
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.
This diagram shows:
master
branchfeature
(because we’re doing ‘feature work’ on this branch)feature
takes before it’s merged into master
步驟2。建立分支
分支是一次處理不一樣版本存儲庫的方法。
默認狀況下,存儲庫有一個名爲master的分支,該分支被視爲最終分支。在將分支提交給master以前,咱們使用分支進行實驗和編輯。
當您在主分支上建立分支時,您正在按主分支在該時間點上的狀態建立主分支的副本或快照。若是其餘人在您處理分支時對主分支進行了更改,您能夠將這些更新拉入。
此圖顯示:
主枝
一個名爲feature的新分支(由於咱們正在對這個分支執行「feature work」)
該功能在融入主功能以前所經歷的旅程
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.
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
.
hello-world
.readme-edits
, into the new branch text box.你保存過不一樣版本的文件嗎?相似於:
TXT
story-joe-edit.txt文件
story-joe-edit-reviewed.txt文件
分支在github存儲庫中實現相似的目標。
在github,咱們的開發人員、做者和設計師使用分支來保持bug修復和功能工做與咱們的主(生產)分支分離。當變化準備好時,他們將分支合併爲master。
建立新分支
轉到新的存儲庫hello world。
單擊文件列表頂部顯示branch:master的下拉列表。
在「新建分支」文本框中鍵入分支名稱「自述編輯」。
選擇藍色的建立分支框或按鍵盤上的「回車」鍵。
Switch branches/tags
切換分支/標記
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編輯。它們看起來如出一轍,但不會過久!下一步咱們將把咱們的更改添加到新的分支。
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.md
file.步驟3。進行和提交更改
好極了!如今,您進入了readme edits分支的代碼視圖,它是master的副本。讓咱們作些編輯。
在github上,保存的更改稱爲提交。每一個提交都有一個關聯的提交消息,這是一個說明,解釋爲何進行了特定更改。提交消息捕獲更改的歷史記錄,以便其餘貢獻者可以理解您所作的操做以及緣由。
進行和提交更改
單擊readme.md文件。
單擊文件視圖右上角的鉛筆圖標進行編輯。
在編輯器中,寫一點關於你本身的東西。
編寫一條描述更改的提交消息。
單擊「提交更改」按鈕。
Commit directly to the readme-edits branch.
直接提交到自述編輯分支。
Create a new branch for this commit and start a pull request. Learn more about pull requests.
爲此提交建立一個新分支並啓動一個拉取請求。瞭解有關拉取請求的更多信息。
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
.
這些更改將僅對「自述編輯」分支上的自述文件進行,所以如今此分支包含與「主控」不一樣的內容。
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 show diffs, or differences, of the content from both branches. The changes, additions, and subtractions are shown in green and red.
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.
Click on the image for a larger version
步驟4。打開拉取請求
尼斯編輯!如今您已經更改了master的分支,能夠打開一個pull請求。
拉取請求是github上協做的核心。當您打開一個請求時,您提出了您的更改,並請求有人檢查和拉入您的貢獻並將其合併到他們的分支中。拉取請求顯示來自兩個分支的內容的差別。更改、添加和減法顯示爲綠色和紅色。
一旦提交,就能夠打開請求並開始討論,甚至在代碼完成以前。
經過在pull請求消息中使用github的@notice系統,您能夠請求特定人員或團隊的反饋,不管他們是在大廳下面仍是10個時區以外。
您甚至能夠在本身的存儲庫中打開pull請求並本身合併它們。在處理更大的項目以前,這是學習github流的好方法。
打開請求更改自述文件
點擊圖片查看更大版本
Click the Pull Request tab, then from the Pull Request page, click the green New pull request button.
In the Example Comparisonsbox, select the branch you made, readme-edits
, to compare with master
(the original).
單擊「拉取請求」選項卡,而後在「拉取請求」頁面中,單擊綠色的「新建拉取請求」按鈕。
在「示例比較」框中,選擇要與主控形狀(原始形狀)進行比較的分支「自述編輯」。
Branches, tags, commit ranges, and time ranges. In the same repository and across forks.
比較和回顧任何事情
分支、標記、提交範圍和時間範圍。在同一個存儲庫中,跨越叉子。
示例比較
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.
當您確信這些是要提交的更改時,請單擊綠色的「建立請求」按鈕。
Able to merge. These branches can be automatically merged.
可以合併。這些分支能夠自動合併。
Discuss and review the changes in this comparison with others.
與其餘人討論並回顧此比較中的更改。
已驗證
Showing 1 changed file with 3 additions and 0 deletions.
顯示1個已更改的文件,包括3個添加和0個刪除。
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!
Tip: You can use emoji and drag and drop images and gifs onto comments and Pull Requests.
完成郵件後,單擊「建立拉取請求」!
提示:您可使用emoji並將圖像和gif拖放到評論和請求中
Step 5. Merge your Pull Request
In this final step, it’s time to bring your changes together – merging your readme-edits branch into the master branch.
Click the green Merge pull request button to merge the changes into master.
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。合併拉取請求
在最後一步中,是時候將您的更改合併到一塊兒了——將您的自述編輯分支合併到主分支中。
單擊綠色的合併請求按鈕將更改合併到主控形狀。
單擊「確認合併」。
繼續並刪除分支,由於它的更改已經合併,紫色框中有delete branch按鈕。
Add more commits by pushing to the readme-edits
branch on wlinjie/hello-world.
經過在wlinjie/hello world上的readme edits分支添加更多提交。
Merging can be performed automatically.
此分支與基分支沒有衝突
合併能夠自動執行。
You can also open this in GitHub Desktop or view command line instructions
您也能夠在github桌面或查看命令行說明中打開它
You’re all set—the readme-edits branch can be safely deleted.
成功合併並關閉拉取請求
您都設置了「自述編輯」分支能夠安全刪除。
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:
慶祝一下!
經過完成本教程,您已經學會了在github上建立項目和發出請求!
如下是您在本教程中完成的內容:
建立了一個開源存儲庫
開始並管理一個新的分支
更改了一個文件並將這些更改提交給github
打開併合並拉取請求
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 the GitHub flow Guide. You might also visit GitHub Explore and get involved in an Open Source project.
看看你的github檔案,你會看到你的新貢獻廣場!
要了解pull請求的強大功能,咱們建議閱讀github流指南。您還能夠訪問github explore並參與一個開源項目。
Tip: Check out our other Guides, YouTube Channel and On-Demand Training for more on how to get started with GitHub.
提示:查看咱們的其餘指南、youtube頻道和點播培訓,瞭解更多關於如何開始使用github的信息。