https://help.github.com/articles/fork-a-repo/
https://help.github.com/articles/using-pull-requests/
Fork A Repo
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea.
Propose changes to someone else's project
A great example of using forks to propose changes is for bug fixes. Rather than logging an issue for a bug you've found, you can:
- Fork the repository.
- Make the fix.
- Submit a pull request to the project owner.
If the project owner likes your work, they might pull your fix into the original repository!
Use someone else's project as a starting point for your own idea.
At the heart of open source is the idea that by sharing code, we can make better, more reliable software.
In fact, when you create a repository on GitHub, you have a choice of automatically including a license file, which determines how you want your project to be shared with others.
Fork an example repository
Forking a repository is a simple two-step process. We've created a repository for you to practice with!
- On GitHub, navigate to the octocat/Spoon-Knife repository.
-
In the top-right corner of the page, click Fork.
That's it! Now, you have a fork of the original octocat/Spoon-Knife repository.
Keep your fork synced
You might fork a project in order to propose changes to the upstream, or original, repository. In this case, it's good practice to regularly sync your fork with the upstream repository. To do this, you'll need to use Git on the command line. You can practice setting the upstream repository using the sameoctocat/Spoon-Knife repository you just forked!
Step 1: Set Up Git
Step 2: Create a local clone of your fork
Right now, you have a fork of the Spoon-Knife repository, but you don't have the files in that repository on your computer. Let's create a clone of your fork locally on your computer.
-
On GitHub, navigate to your fork of the Spoon-Knife repository.
-
Under your repository name, click to copy the clone URL for the repository.
-
Open Terminal.
-
Type git clone
, and then paste the URL you copied in Step 2. It will look like this, with your GitHub username instead of YOUR-USERNAME
:
git clone https://github.com/YOUR-USERNAME/Spoon-Knife
-
Press Enter. Your local clone will be created.
git clone https://github.com/YOUR-USERNAME/Spoon-Knife
Cloning into `Spoon-Knife`...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (8/8), done.
remove: Total 10 (delta 1), reused 10 (delta 1)
Unpacking objects: 100% (10/10), done.
Now, you have a local copy of your fork of the Spoon-Knife repository!
Step 3: Configure Git to sync your fork with the original Spoon-Knife repository
When you fork a project in order to propose changes to the original repository, you can configure Git to pull changes from the original, or upstream, repository into the local clone of your fork.
-
On GitHub, navigate to the octocat/Spoon-Knife repository.
-
Under your repository name, click to copy the clone URL for the repository.
-
Open Terminal.
-
Change directories to the location of the fork you cloned in Step 2: Create a local clone of your fork.
- To go to your home directory, type just
cd
with no other text.
- To list the files and folders in your current directory, type
ls
.
- To go into one of your listed directories, type
cd your_listed_directory
.
- To go up one directory, type
cd ..
.
-
Type git remote -v
and press Enter. You'll see the current configured remote repository for your fork.
git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
-
Type git remote add upstream
, and then paste the URL you copied in Step 2 and pressEnter. It will look like this:
git remote add upstream https://github.com/octocat/Spoon-Knife.git
-
To verify the new upstream repository you've specified for your fork, type git remote -v
again. You should see the URL for your fork as origin
, and the URL for the original repository as upstream
.
git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
Now, you can keep your fork synced with the upstream repository with a few Git commands. For more information, see "Syncing a fork."
Next Steps
The sky's the limit with the changes you can make to a fork, including:
-
Creating branches: Branches allow you to build new features or test out ideas without putting your main project at risk.
-
Opening pull requests: If you are hoping to contribute back to the original repository, you can send a request to the original author to pull your fork into their repository by submitting a pull request.
Using pull requests
Pull requests let you tell others about changes you've pushed to a repository on GitHub. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits if necessary.
This guide walks through the process of sending a hypothetical pull request and using the various code review and management tools to take the change to completion.
Before you begin
This guide assumes that you have a GitHub account, that you've forked an existing repository, and that you've pushed changes to your fork. For help with forking and pushing changes, see the Forking a Repo article.
Initiating the pull request
In the following example, Hubot has completed some work on a fork of the Octocat's Spoon-Knife repository, pushed a commit to a topic branch in his fork, and would like someone to review and merge.
Navigate to your repository with the changes you want someone else to pull and press the Pull Requestbutton.
-
Switch to your branch.
-
Click New pull request.

You can send pull requests from any branch or commit but we recommend that you use a topic branch. That way, you can push follow-up commits if you need to update the pull request.
Reviewing the pull request
After starting the review, you're presented with a review page where you can get a high-level overview of the changes between your branch and the repository's master
branch. You can review all comments made on commits, identify which files changed, and get a list of contributors to your branch.

Changing the branch range and destination repository
By default, pull requests are based on the parent repository's default branch. In this case, thehubot/Spoon-Knife
repository was forked from octocat/Spoon-Knife
so the pull request is based on the master
branch of the octocat/Spoon-Knife
repository.
If the default parent repository isn't correct, you can change both the parent repository and the branch with the drop-down lists. You can also swap your head and base with the drop-down lists to establish diffs between reference points. References here must be branch names in your GitHub repository.

The easiest way of thinking about the branch range is this: the base branch is where you think changes should be applied, the head branch is what you would like to be applied.
When you change the base repository, you also change notifications for the pull request. Everyone that can push to the base repository will receive an email notification and see the new pull request in their dashboard the next time they sign in.
When you change any of the info in the branch range, the commit and files changed preview areas will update to show your new range.
Using the compare view, you can set up comparisons across any arbitrary timeframe.
Sending the pull request
When you're ready to submit your pull request, click Create pull request.

- Enter a title and optional description in the discussion page. In this view, you can see the commits that are included once you send the pull request.
- Make any necessary customizations to the commit range and review the commits and file changes.
-
Click the Create pull request button.
After you send a pull request, any commit that's pushed to your branch will be automatically added to your pull request, which is useful if you're making additional changes.
Managing pull requests
In the request dashboard, you can browse pull requests that you've sent or received. You can also view pull requests for any repository to which you have access via the Pull Requests page.

The pull request dashboard and the repository pull request list have filtering and sorting controls that you can use to narrow down the list to the pull requests you're interested in.
Reviewing proposed changes
Once you receive a pull request, you can review the proposed changes. The commits in the pull request show you what will be merged with the underlying git repository if the pull request is accepted.

You can also review the cumulative diff of all file changes across all commits, either split or unified.

Pull request discussion
After reviewing the basic description, commits, and cumulative diff, the person tasked with applying the changes may have questions or comments. Perhaps the coding style doesn't match project guideline, or the change is missing unit tests, or maybe everything looks great and some props are in order. The discussion view encourages and captures this type of discussion.

The discussion view begins with the pull request's original title and description and then chronologically lists additional activity. The following types of activity are captured as they occur:
- Comments left on the pull request itself
- Additional commits pushed to the pull request's branch
- File and line notes left on any of the commits included in the pull request's range
Pull request comments are Markdown compatible so you can embed images, use pre-formatted text blocks, and perform other formatting supported by Markdown.
Viewing long-running pull requests
When a pull request seems to linger for an extended period of time without making any progress, you may want to review it to understand what's blocking it from being resolved. You can find still-active pull requests by viewing and sorting long-running pull requests from your repository's Pull Request page.

Long-running pull requests exist for more than a month and have seen activity within the past month. This filter displays those long-running pull requests sorted by life span: the amount of time from creation to the most recent activity.
Further reading
相关推荐
1. 完整流程:Github 的项目—>fork 到自己的 Github 网站分支—>clone 到自己的本地版本—>修改后 push 到自己的 Github 网站分支—>将自己 Github 网站分支 pull request 到 Github 的原项目 2. 将原项目的修改...
"前端开源库-pull-request"的主题聚焦于如何利用GitHub API进行版本控制操作,特别是关于拉取请求(Pull Request,简称PR)的工作流程。拉取请求是GitHub上用于协同开发的核心功能,它允许开发者从一个分支(通常为...
这篇“GitHub提交说明1”主要涉及如何向GitHub上的公共仓库贡献代码,特别是通过fork和pull request的方式来实现这一目标。 首先,我们需要了解什么是fork。在GitHub上,当你对某个项目感兴趣并想参与其中,但没有...
如何加入使用 GitHub 的 Fork & Pull Request 机制,你不必成为该计划的一员就可以参与该计划。加入我们意味着承担更多的责任,你需要参与讨论,review 他人的代码,回答社区的疑问等等。你可以 ,在 _data/members....
3. 协作开发:GitHub提供了代码托管平台,开发者可以通过fork和pull request与其他团队成员或社区进行协作。 4. 代码审核:GitHub的Pull Request机制鼓励代码审查,有助于保持代码质量并减少错误。 5. 开源共享:...
然后在GitHub上,从你的Fork的`your-feature-branch`创建一个Pull Request到原项目的主分支(通常是`master`或`main`)。 ### 8. Pull Request审查与合并 项目维护者会检查你的PR,可能要求进行修改,添加测试,...
如果希望将这些改动合并回原始项目,可以发起Pull Request。 5. **个人网站**:这个项目是一个个人网站,可能包含关于作者的信息、作品展示、博客文章等内容,用HTML、CSS和JavaScript等技术编写。 6. **Markdown*...
Fork / Pull request 邮件通知 动态 用户管理(仅限管理员) 用户组(和Github的组织类似) LDAP支持 Gravatar支持 以下功能尚未支持,但是将会在未来的版本中可用! ...
本教程将指导你如何在GitHub上fork一个项目并同步原作者的修改。 首先,确保你已经拥有一个GitHub账号,如果没有,只需要提供用户名、邮箱和密码即可注册。注册完成后,你可以搜索感兴趣的项目。例如,假设你想贡献...
- **Fork and Pull Request** 工作流:用于开源项目贡献。 - **Feature Branch** 工作流:每个开发者在自己的分支上工作,然后合并到主分支。 - **GitFlow** 工作流:包括主分支(master)、开发分支(develop)...
随后,重点讲解GitHub的功能,如仓库的创建、克隆、fork、pull request等,这些功能使得开发者能够方便地参与项目、提出建议和修复问题。 GitHub的Pull Request是其最具代表性的特性之一。通过Pull Request,开发者...
本实践项目“repo-fork-exercise”旨在帮助用户熟悉GitHub上的两个核心操作:fork和pull request。 **Fork** 是GitHub上的一个特性,允许用户复制其他用户的仓库到自己的GitHub账户中。在这个过程中,源仓库(原...
- 提交Pull Request:在GitHub界面上,提交Pull Request是一个将你的更改分享给原始项目的开发者的正式请求。 7. 安全性的考量 - 在直接使用`git pull`命令时,需要谨慎,因为它会直接合并远程分支到当前分支。...
- **定义:** 当你完成了对 Fork 的项目进行修改后,可以发起 Pull Request 请求将这些更改合并回原始项目。 - **示例:** 在上述例子中,php 大牛完成前端代码优化后,可以向原始“知乎首页”项目发起 Pull Request...
GitHub 进行多人协作开发的过程,包括登录 Git 账号、建立本机电脑和 GitHub 远程仓库的连接、fork 别人仓库、clone 到本地、通过 Git 修改编辑、更新内容、将本地仓库更新至远程仓库、发送 pull request 给作者等...
在IT行业中,GitHub是一个至关重要的平台,它是一个用于版本控制和协作的...通过熟练掌握Fork、Pull Request以及处理空文件夹等技巧,开发者可以在GitHub上积极参与开源项目,提升自己的技能,并为整个社区做出贡献。
4. **拉取请求(Pull Request)**:当你在本地完成代码修改并希望合并到主分支时,会发起一个拉取请求,等待其他成员审核。 5. **Git**:GitHub 基于 Git 进行版本控制,Git 是一个分布式版本控制系统,用于跟踪对...
**创建Pull Request**:在GitHub上创建Pull Request,将你的更改贡献给原始项目。 - **GitHub Forks的最佳实践**: - **保持Fork同步**:定期从原始项目拉取更改,减少与原始项目的冲突。 - **使用特性分支**:...
通过 GitHub 向我发送 Pull Request。 -- 蒋鑫, http://weibo.com/gotgit/ 目录 1. 探索GitHub 1.1. 什么是GitHub 1.2. GitHub亮点 1.3. 探索GitHub 2. 加入GitHub 2.1. 创建GitHub账号 2.2. ...
GitHub for Mac 是一款专为苹果Mac OS X操作系统设计的图形用户界面(GUI)工具,它使得用户可以更轻松地与GitHub进行交互,包括克隆仓库、创建分支、提交更改、推送代码以及管理Pull Request等操作。这款客户端是...