zoukankan      html  css  js  c++  java
  • git-format-patch

    使用方法:

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

    git 帮助信息:

    git format-patch  -h
    usage: 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 <header>
                              add email header
        --to <email>          add To: header
        --cc <email>          add Cc: header
        --from[=<ident>]      set From address to <ident> (or committer ident if absent)
        --in-reply-to <message-id>
                              make first mail a reply to <message-id>
        --attach[=<boundary>]
                              attach the patch
        --inline[=<boundary>]
                              inline the patch
        --thread[=<style>]    enable message threading, styles: shallow, deep
        --signature <signature>
                              add a signature
        --base <base-commit>  add prerequisite tree info to the patch series
        --signature-file <file>
                              add a signature from a file
        -q, --quiet           don't print the patch filenames

    git 变量KV命名:

    git -h
    Unknown option: -h
    usage: 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.两种patch的比较:

    • 兼容性:很明显,git diff生成的Patch兼容性强。如果你在修改的代码的官方版本库不是Git管理的版本库,那么你必须使用git diff生成的patch才能让你的代码被项目的维护人接受。
    • 除错功能:对于git diff生成的patch,你可以用git apply --check 查看补丁是否能够干净顺利地应用到当前分支中;如果git format-patch 生成的补丁不能打到当前分支,git am会给出提示,并协助你完成打补丁工作,你也可以使用git am -3进行三方合并,详细的做法可以参考git手册或者《Progit》。从这一点上看,两者除错功能都很强。
    • 版本库信息:由于git format-patch生成的补丁中含有这个补丁开发者的名字,因此在应用补丁时,这个名字会被记录进版本库,显然,这样做是恰当的。因此,目前使用Git的开源社区往往建议大家使用format-patch生成补丁。
     
     
  • 相关阅读:
    跨站的艺术-XSS Fuzzing 的技巧
    腾讯云数据库团队:PostgreSQL TOAST技术理解
    Git commit message和工作流规范
    前端识别验证码思路分析
    Akamai在内容分发网络中的算法研究(翻译总结)
    Nginx网站使用CDN之后禁止用户真实IP访问的方法
    常用机器性能评估工具
    解决关于ArcGIS10.2服务手动启动的问题
    林业通用平台上线
    土地承包经营权地块示意图打印
  • 原文地址:https://www.cnblogs.com/suanec/p/9892123.html
Copyright © 2011-2022 走看看