From 401f0388c3ed7806db6254be6eb780b6ca9d1f20 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 8 Apr 2023 11:44:32 +0200 Subject: [PATCH] git-am, git-apply: add and tweak remote patch examples (#10019) `curl` now uses the `-L` option to follow redirects, which is required when applying patch files from GitHub URLs. The example was also added to `git-am` where it works too. The difference between `git-am` and `git-apply` was also clarified in each command's description. --- pages/common/git-am.md | 8 ++++++-- pages/common/git-apply.md | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pages/common/git-am.md b/pages/common/git-am.md index 4b170737a..d22019a92 100644 --- a/pages/common/git-am.md +++ b/pages/common/git-am.md @@ -1,13 +1,17 @@ # git am -> Apply patch files. Useful when receiving commits via email. +> Apply patch files and create a commit. Useful when receiving commits via email. > See also `git format-patch`, which can generate patch files. > More information: . -- Apply a patch file: +- Apply and commit changes following a local patch file: `git am {{path/to/file.patch}}` +- Apply and commit changes following a remote patch file: + +`curl -L {{https://example.com/file.patch}} | git apply` + - Abort the process of applying a patch file: `git am --abort` diff --git a/pages/common/git-apply.md b/pages/common/git-apply.md index 5b5757916..9687569ed 100644 --- a/pages/common/git-apply.md +++ b/pages/common/git-apply.md @@ -1,6 +1,7 @@ # git apply -> Apply a patch to files and/or to the index. +> Apply a patch to files and/or to the index without creating a commit. +> See also `git am`, which applies a patch and also creates a commit. > More information: . - Print messages about the patched files: @@ -13,7 +14,7 @@ - Apply a remote patch file: -`curl {{https://example.com/file.patch}} | git apply` +`curl -L {{https://example.com/file.patch}} | git apply` - Output diffstat for the input and apply the patch: