SVN and Git difference between two versions of a control system generation and application of patch.
A, SVN:
1, generated patch between the specified version:
svn diff -r 421 : 438 .> r421_438 Patch // is after all the changes the current directory r421, r421 does not include the modifications
diff -r 421: 422 all modifications of the current directory r422.
diff -c 422 to keep his party in expressing the changes r422.
2, svn application patch:
p1: numeral 1 denotes a document depth, i.e. the directory, according to need to modify the path + file patch determined current directory.
For example: Project TestAndroid source directory: .... / TestAndroid / test / media / ...
test.patch file path: --- a / media / ....
where A is not a valid path, as described below depending on the current directory, the corresponding command parameter
when the current directory is test /, patch -p1. .....
when the current directory for the media /, patch -p0 ......
Two, Git:
1, generates patch
(1) between the two modified commit (comprising two commit) -o [behind this point is to generate patch folder name, in this case all the patch are the directory]
git format-patch <r1>..<r2>
如:
git format-patch d77aaac74845435744c49ae65511d9e1be79ed5c 046ee8f8423302f5070ca81b4e246516e919cd7a -o patchDir
(2) a single commit
Git the format -1-Patch <r1>
Git the format -n-Patch <r1> [submit node r1 forwardly from the n nodes (including r1)]
(3) Since the modification of a commit ( does not contain the commit) [remember: generating a time, not a patch file; instead, each will generate a patch file submitted]
git format-patch <r1>
2, inspection and application patch
(1) copy of the patch generated by the target file to the directory git
(2) Check the patch file
git Apply --stat-0001-fix.patch Minor
(. 3) can be applied successfully to see if
git apply --check 0001-minor-fix .patch
(4) application Patch
git the apply 0001-Minor-fix.patch [only application has not been submitted; view the status is displayed as M]
(5) another way: [application and submit, is not recommended]
git am -s <0001-minor-fix.patch Usage -s Signed-off-by information submitted will appear in the record, the signature information]
or git am <0001-minor-fix.patch [as the case may be]
3, the original reference: http://www.linuxidc.com/Linux/2014-09/106323.htm
4, on the git in a little patch of thinking:
(1) self-test at a local Git Bash in, git patch use for a directory or file?
Above unreasonable, impossible to patch against a directory or file; because: When modifying a bug may involve more than one file, this patch is generated according to a commit to generate, so that makes sense, is completed .
If the patch is only for generating a file, it is likely not a complete submission, there is no practical significance!