Creating a patch from GitHub pull request
In this article, I am going to introduce you little hidden feature in GitHub that I recently found out.
Recently I wanted to create a patch from the GitHub pull request to apply it in my local repository. We may have done it easily with cherry-pick. But here is some amazing hidden feature to create a patch file from the GitHub.
- Go to your pull request.
2. In the above screenshot, you can see the pull request URL. Now what you have to do is, type .patch at the end of the URL and refresh the URL or press enter to go the URL. You will be redirected to the mail-formatted patch file, that is a little different from a usual patch file and it has e-mail metadata as well.
3. Now you can download the patch file and rename it as .patch file if it is downloaded as <name>.patch.txt.
4. Apply the patch using git commands or via your IDE.
#git apply --stat file.patch
#git apply --check file.patch
#git apply file.patch
Furthermore, you can refer to my Most frequently used Git commands article.
Thank you for coming back and referring to my articles. Please feel free to comment and let me know if I am wrong.
And give some claps if this helps you.