Git-format-patch

Source: Internet
Author: User

Usage:

git diff ${old-commit} ${new-commit}  > commit-operation.patchORgit format-patch --stdout -1 b1af44f > commit-operation.patch (recommend)THEN git apply commit-operation.patch

 

Git help information:

git format-patch  -husage: git format-patch [<options>] [<since> | <revision-range>]    -n, --numbered        use [PATCH n/m] even with a single patch    -N, --no-numbered     use [PATCH] even with multiple patches    -s, --signoff         add Signed-off-by:    --stdout              print patches to standard out    --cover-letter        generate a cover letter    --numbered-files      use simple number sequence for output file names    --suffix <sfx>        use <sfx> instead of ‘.patch‘    --start-number <n>    start numbering patches at <n> instead of 1    -v, --reroll-count <n>                          mark the series as Nth re-roll    --rfc                 Use [RFC PATCH] instead of [PATCH]    --subject-prefix <prefix>                          Use [<prefix>] instead of [PATCH]    -o, --output-directory <dir>                          store resulting files in <dir>    -k, --keep-subject    don‘t strip/add [PATCH]    --no-binary           don‘t output binary diffs    --zero-commit         output all-zero hash in From header    --ignore-if-in-upstream                          don‘t include a patch matching a commit upstream    -p, --no-stat         show patch format instead of default (patch + stat)Messaging    --add-header 

 

Name the GIT variable KV:

git -hUnknown option: -husage: git [--version] [--help] [-C <path>] [-c name=value]           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]           <command> [<args>]
# For Example git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree format-patch --stdout -1 b1af44f > commit-operation.patch

 

3. Comparison of the two patches:
  • Compatibility: Obviously, the patch generated by git diff is compatible. If the official version of the modified Code is not managed by git, you must use the patch generated by git diff to make your code accepted by the Project maintainer.
  • Debugging function: for the patch generated by git diff, you can use git apply -- check to check whether the patch can be successfully applied to the current branch; if the patch generated by git format-patch cannot reach the current branch, git am will give a prompt and help you complete the patching. You can also use git am-3 for three-way merge, for details, refer to the GIT manual or progit. From this point of view, both of them have powerful debugging functions.
  • Version Library Information: Because the patch generated by git format-patch contains the name of the patch developer, the name will be recorded in the version library when applying the patch. Obviously, this is appropriate. Therefore, we recommend that you use format-patch to generate patches for open-source communities using git.

 

Git-format-patch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.