mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 13:56:22 -04:00
update 'how-to-pull-request-fork-github'
This commit is contained in:
parent
7b5f3a3be8
commit
2f57852f12
@ -13,24 +13,20 @@ image: "step7-2.png"
|
|||||||
draft: false
|
draft: false
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
{{< image src="images/forks.png" alt="Git Forks Visualization" />}}
|
{{< image src="images/forks.png" alt="Git Forks Visualization" />}}
|
||||||
|
|
||||||
|
|
||||||
Contributing to an open-source project can be intimidating at first. The convoluted process of submitting your improvements for approval via a [**pull request**](https://help.github.com/en/articles/about-pull-requests) certainly doesn't help.
|
Contributing to an open-source project can be intimidating at first. The convoluted process of submitting your improvements for approval via a [**pull request**](https://help.github.com/en/articles/about-pull-requests) certainly doesn't help.
|
||||||
|
|
||||||
The following steps to submit a pull request will work on Git repositories hosted anywhere — on [GitLab](https://gitlab.com/), [Bitbucket](https://bitbucket.org/), [Azure DevOps](https://azure.microsoft.com/en-us/services/devops/repos/), etc. — but most open-source repositories one would want to contribute to are likely on [**GitHub**](https://github.com/), which is what we'll be using.
|
The following steps to submit a pull request will work on Git repositories hosted anywhere — on [GitLab](https://gitlab.com/), [Bitbucket](https://bitbucket.org/), [Azure DevOps](https://azure.microsoft.com/en-us/services/devops/repos/), etc. — but most open-source repositories one would want to contribute to are likely on [**GitHub**](https://github.com/), which is what we'll be using.
|
||||||
|
|
||||||
Starting from the very beginning, we'll fork an existing repository to our account, clone the fork locally, commit your changes to a new branch, and push it back upstream to GitHub to submit for approval.
|
Starting from the very beginning, we'll fork an existing repository to our account, clone the fork locally, commit your changes to a new branch, and push it back upstream to GitHub to submit for approval.
|
||||||
|
|
||||||
|
|
||||||
## 1. Forking the Repository
|
## 1. Forking the Repository
|
||||||
|
|
||||||
Assuming you're using GitHub, this step is easy. Just find the repository you're contributing to and press the Fork button in the upper left. This will create an exact copy of the repository (and all of its branches) under your own username.
|
Assuming you're using GitHub, this step is easy. Just find the repository you're contributing to and press the Fork button in the upper left. This will create an exact copy of the repository (and all of its branches) under your own username.
|
||||||
|
|
||||||
{{< image src="images/step1.png" alt="Step 1" />}}
|
{{< image src="images/step1.png" alt="Step 1" />}}
|
||||||
|
|
||||||
|
|
||||||
## 2. Clone your new fork locally
|
## 2. Clone your new fork locally
|
||||||
|
|
||||||
GitHub will automatically redirect you to the forked repository under your username. This is the repository you need to clone to your local development environment, **not** the original. Grab the URL GitHub provides under the green "Clone or Download" button and plug it into the command below.
|
GitHub will automatically redirect you to the forked repository under your username. This is the repository you need to clone to your local development environment, **not** the original. Grab the URL GitHub provides under the green "Clone or Download" button and plug it into the command below.
|
||||||
@ -41,10 +37,11 @@ git clone git@github.com:jakejarvis/react-native.git
|
|||||||
|
|
||||||
{{< image src="images/step2.png" width="420" alt="Step 2" />}}
|
{{< image src="images/step2.png" width="420" alt="Step 2" />}}
|
||||||
|
|
||||||
|
|
||||||
## 3. Track the original repository as a remote of the fork
|
## 3. Track the original repository as a remote of the fork
|
||||||
|
|
||||||
Once you've forked a repository, changes to the original (or "upstream") repository are not pushed to your fork. We need to tell the new repository to follow changes made upstream to keep it fresh via [something called a `remote`](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes).
|
_This step is technically optional, but important if you plan to continue contributing to a project in the future, so we might as well..._
|
||||||
|
|
||||||
|
Once you've forked a repository, changes to the original (or "upstream") repository are not pushed to your fork. We need to tell the new repository to follow changes made upstream to keep it fresh via [remotes](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes).
|
||||||
|
|
||||||
Switch directories to the forked repository you just cloned and run the following commands. Replace the last part of the first line with the **original** repository clone URL — similar to the how you grabbed the URL in step 2, but this **isn't** the one with your username.
|
Switch directories to the forked repository you just cloned and run the following commands. Replace the last part of the first line with the **original** repository clone URL — similar to the how you grabbed the URL in step 2, but this **isn't** the one with your username.
|
||||||
|
|
||||||
@ -55,7 +52,6 @@ git remote add --track master upstream git@github.com:facebook/react-native.git
|
|||||||
git fetch upstream
|
git fetch upstream
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 4. Create a new branch for your changes
|
## 4. Create a new branch for your changes
|
||||||
|
|
||||||
It's possible to make changes directly to the `master` branch, but this might FUBAR things down the road for complicated reasons. It's best to [`checkout`](https://git-scm.com/docs/git-checkout) a new branch for **each** change/improvement you want to make. Replace `fix-readme-typo` with a more descriptive name for your changes, like `add-mobile-site` or `update-dependencies`.
|
It's possible to make changes directly to the `master` branch, but this might FUBAR things down the road for complicated reasons. It's best to [`checkout`](https://git-scm.com/docs/git-checkout) a new branch for **each** change/improvement you want to make. Replace `fix-readme-typo` with a more descriptive name for your changes, like `add-mobile-site` or `update-dependencies`.
|
||||||
@ -64,12 +60,10 @@ It's possible to make changes directly to the `master` branch, but this might FU
|
|||||||
git checkout -b fix-readme-typo upstream/master
|
git checkout -b fix-readme-typo upstream/master
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 5. Make your changes!
|
## 5. Make your changes!
|
||||||
|
|
||||||
This is either the easiest part or the hardest part, depending on how you look at it. 😉 At this point, you're isolated in the new branch you just created, and it's safe to open whatever text editor or IDE you use and go wild.
|
This is either the easiest part or the hardest part, depending on how you look at it. 😉 At this point, you're isolated in the new branch you just created, and it's safe to open whatever text editor or IDE you use and go wild.
|
||||||
|
|
||||||
|
|
||||||
## 6. Add, commit, and push the changes
|
## 6. Add, commit, and push the changes
|
||||||
|
|
||||||
You're probably used to these commands. Add the files you've changed and commit them with a descriptive message.
|
You're probably used to these commands. Add the files you've changed and commit them with a descriptive message.
|
||||||
@ -85,7 +79,6 @@ The one difference is the branch you're pushing to. You likely usually push to `
|
|||||||
git push -u origin fix-readme-typo
|
git push -u origin fix-readme-typo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 7. Submit your pull request
|
## 7. Submit your pull request
|
||||||
|
|
||||||
You're now all ready to submit the improvement you've made to the project's maintainers for approval. Head over to the original repositories Pull Requests tab, and you should see an automatic suggestion from GitHub to create a pull request from your new branch.
|
You're now all ready to submit the improvement you've made to the project's maintainers for approval. Head over to the original repositories Pull Requests tab, and you should see an automatic suggestion from GitHub to create a pull request from your new branch.
|
||||||
@ -96,4 +89,4 @@ You're now all ready to submit the improvement you've made to the project's main
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
I'll admit, I need to refer back to these notes whenever I'm preparing to contribute to an open-source project. It's certainly not the most intuitive process, but at least it's the same wherever the project is located — for example, I host my [own private GitLab CE instance](https://git.jarv.is/jake). The universality of Git is what makes it great! 👍
|
I'll admit, I need to refer back to these notes sometimes when I'm preparing to contribute to an open-source project. It's certainly not the most [intuitive](https://ohshitgit.com/) process, but at least it's **exactly the same** wherever the project is located — for example, I host my own [small Gitea server](https://code.jarv.is/) to back up some of my GitHub account. This instant compatibility between completely different services is precisely what makes Git great! 🏆
|
||||||
|
Loading…
x
Reference in New Issue
Block a user