Learn Git and GitHub

 

Learn Git and GitHub without any code!

Using the Hello World guide, you’ll start a branch, write comments, and open a pull request.git

Read the guide

https://guides.github.com/activities/hello-world/github

Hello World

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:浏览器

  • 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

     

  • hello world项目是计算机编程中一个由来已久的传统。这是一个简单的练习,让你开始学习新东西。让咱们从github开始吧!
    你将学习如何:
    建立和使用存储库
    启动和管理新分支
    对文件进行更改并将其做为提交推送到github
    打开并合并拉取请求安全

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 repositoriesbranchescommits, 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

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.ui

什么是Github?
github是一个用于版本控制和协做的代码托管平台。它让你和其余人在任何地方的项目上一块儿工做。
本教程将向您介绍GitHub的基本功能,如存储库、分支、提交和拉取请求。您将建立本身的hello world存储库,并学习github的pull-request工做流,这是一种建立和审查代码的流行方法。
无需编码
要完成本教程,您须要github.com账户和Internet访问。您不须要知道如何编写代码、使用命令行或安装git(版本控制软件github是基于github构建的)。
提示:在单独的浏览器窗口(或选项卡)中打开此指南,以便在完成教程中的步骤时能够看到它。this

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。建立存储库
存储库一般用于组织单个项目。存储库能够包含文件夹和文件、图像、视频、电子表格和数据集—任何项目须要的内容。咱们建议包括一个自述文件,或者一个包含项目信息的文件。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.

单击建立存储库。

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.

This diagram shows:

  • The master branch
  • A new branch called feature (because we’re doing ‘feature work’ on this branch)
  • The journey that 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.

To create a new branch

  1. Go to your new repository hello-world.
  2. Click the drop down at the top of the file list that says branch: master.
  3. Type a branch name, readme-edits, into the new branch text box.
  4. Select the blue Create branch box or hit “Enter” on your keyboard.

你保存过不一样版本的文件吗?相似于:
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编辑。它们看起来如出一辙,但不会过久!下一步咱们将把咱们的更改添加到新的分支。

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

Make and commit changes

  1. Click the README.md file.
  2. Click the  pencil icon in the upper right corner of the file view to edit.
  3. In the editor, write a bit about yourself.
  4. Write a commit message that describes your changes.
  5. Click Commit changes button.

步骤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-editsbranch, so now this branch contains content that’s different from 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 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.

Open a Pull Request for changes to the README

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).

单击“拉取请求”选项卡,而后在“拉取请求”页面中,单击绿色的“新建拉取请求”按钮。
在“示例比较”框中,选择要与主控形状(原始形状)进行比较的分支“自述编辑”。

Compare changes

Compare changes across branches, commits, tags, and more below. If you need to, you can also  compare across forks.

比较更改
比较分支、提交、标记和下面更多内容之间的更改。若是你须要的话,你也能够用叉子来比较。

Choose different branches or forks above to discuss and review changes.

选择以上不一样的分支或分支来讨论和评审更改。

Compare and review just about anything

Branches, tags, commit ranges, and time ranges. In the same repository and across forks.

 

比较和回顾任何事情
分支、标记、提交范围和时间范围。在同一个存储库中,跨越叉子。

  • EXAMPLE COMPARISONS

示例比较

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.

与其余人讨论并回顾此比较中的更改。

 Verified

已验证

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分支添加更多提交。

This branch has no conflicts with the base branch

Merging can be performed automatically.

此分支与基分支没有冲突
合并能够自动执行。

You can also open this in GitHub Desktop or view command line instructions

您也能够在github桌面或查看命令行说明中打开它

Pull request successfully merged and closed

You’re all set—the readme-edits branch can be safely deleted.

成功合并并关闭拉取请求
您都设置了“自述编辑”分支能够安全删除。

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

庆祝一下!
经过完成本教程,您已经学会了在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 GuidesYouTube Channel and On-Demand Training for more on how to get started with GitHub.

 

提示:查看咱们的其余指南、youtube频道和点播培训,了解更多关于如何开始使用github的信息。

相关文章
相关标签/搜索