cg-patch - apply a patch from a file, standard input, or a commit
cg-patch [-c] [-C COMMIT] [-pN] [-R] [-u] [OTHER_OPTIONS] < PATCH
Apply a patch in a manner similar to the patch tool, but while also handling the Git extensions to the diff format: file mode changes, file renames, distinguishing removal of files and empty files, etc. Newly created files are automatically cg-add(1)ed and removed files are cg-rm(1)oved.
cg-patch(1) can also automatically commit the applied patches and extract patches from existing commits, therefore effectively enabling you to cherrypick certain changes from a different branch.
In comparasion with the git-apply tool, cg-patch(1) will also apply fuzzy patches.
Automatically extract the commit message and authorship information (if provided) from the patch and commit it after applying it successfuly.
Instead of applying a patch from stdin, apply and commit the patch introduced by the given commit. This is basically an extension of cg-commit -c.
In combination with -R, this does the opposite - it will revert the given commit and then try to commit a revert commit - it will prefill the headline and open the commit editor for you to write further details.
Note that even though this is functionally equivalent to the cherry-picking concept present in other version control systems, this does not play very well together with regular merges and if you both cherry-pick and merge between two branches, the picking may increase the number of conflicts you will get when merging.
Instead of applying a patch from stdin, apply and separately commit all patches in the specified directory. This can be used to import a range of patches made by cg-mkpatch -d. Implies -c.
Strip path of filenames in the diff to the level N. This works exactly the same as in the patch tool except that the default strip level is not infinite but 1 (or more if you are in a subdirectory; in short, cg-diff | cg-patch -R and such always works).
Apply the patch in reverse (therefore effectively unapply it).
In case -d failed in some patch in the middle with conflicts and you resolved them, running cg-patch with with the -d argument as well as --resolved will cause it to pick up where it dropped off and go on applying. (This includes committing the failed patch; do not commit it on your own!)
Make cg-patch(1) assume the patch on the input is a classic unified diff instead of a diff produced by GIT or Cogito. This means only that file adds and removals will be recorded even if the patch file does not explicitly describe them. Use this if the patch was not produced by cg-diff(1) or similar but by a traditional diff tool.
Takes the diff on stdin (unless specified otherwise).
Print usage summary.
Print user manual. The same as found in cg-patch(1).
Copyright © Petr Baudis, 2005