add patch workflow to sharing code section (#307)

This commit is contained in:
CEUK 2020-11-28 21:15:14 +00:00 committed by GitHub
parent cfca81c274
commit 82f0b3994d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -30,6 +30,7 @@ All commands should work for at least git version 2.13.0. See the [git website](
- [I set the wrong remote repository](#i-set-the-wrong-remote-repository)
- [I want to add code to someone else's repository](#i-want-to-add-code-to-someone-elses-repository)
- [Suggesting code via pull requests](#suggesting-code-via-pull-requests)
- [Suggesting code via patches](#suggesting-code-via-patches)
- [I need to update my fork with latest updates from the original repository](#i-need-to-update-my-fork-with-latest-updates-from-the-original-repository)
- [Editing Commits](#editing-commits)
- [What did I just commit?](#what-did-i-just-commit)
@ -237,6 +238,20 @@ There is no way to suggest a pull request using the CLI using Git (although ther
After all of this, do not forget to respond to any code review feedback.
#### Suggesting code via patches
Another approach to suggesting code changes that doesn't rely on third party sites such as Github is to use `git format-patch`.
`format-patch` creates a .patch file for one or more commits. This file is essentially a list of changes that looks similar to the commit diffs you can view on Github.
A patch can be viewed and even edited by the recipient and applied using `git am`.
For example, to create a patch based on the previous commit you would run `git format-patch HEAD^` which would create a .patch file called something like 0001-My-Commit-Message.patch.
To apply this patch file to your repository you would run `gim am ./0001-My-Commit-Message.patch`.
Patches can also be sent via email using the `git send-email` command. For information on usage and configuration see: https://git-send-email.io
#### I need to update my fork with latest updates from the original repository
After a while, the `upstream` repository may have been updated, and these updates need to be pulled into your `origin` repo. Remember that like you, other people are contributing too. Suppose that you are in your own feature branch and you need to update it with the original repository updates.