Browse Source

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.
Hugo Locurcio 1 year ago
parent
commit
401f0388c3
2 changed files with 9 additions and 4 deletions
  1. 6 2
      pages/common/git-am.md
  2. 3 2
      pages/common/git-apply.md

+ 6 - 2
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: <https://git-scm.com/docs/git-am>.
 
-- 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`

+ 3 - 2
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: <https://git-scm.com/docs/git-apply>.
 
 - 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: