diff
and patch
command to patch files
- use
diff
command to generate patch file
1
| diff -u old_file new_file > change.patch
|
- apply
patch
to change old file to new one
1
| patch old_file change.patch
|
-u
parameter will make the diff output use unified output format, which
is easy-to-read like git diff
’s output. It is optional.
git diff
usage
- get the changes between the workspace and staging area
1
| git diff > change.patch
|
- get the change between an old version of your local repository and new one.
1
| git diff old_commit_hash new_commit_hash > change.patch
|
- diff for one file but not whole folder
1
| git diff old_commit new_commit $file_name > change.patch
|
- apply patches
git reflog
will show a more short commit hash code which is enough for the
git diff
command