git diff

git diff HEAD HEAD~1

git diff main feature/abc

git diff main feature/abc hello.cpp

比较分支的提交差异

| dev    | 存在   |
| master | 不存在 |
git log dev ^master
git log master..dev
| dev    | 不存在 |
| master | 存在   |
git log master ^dev
git log dev..master
| dev    | 不存在 |     | dev    | 存在   |
| master | 存在   |  +  | master | 不存在 |
git log dev...master

对比两个分支不一样,同时标记提交在哪个分支上:

git log --left-right dev...master

    <              >
    --left-right
    < dev...master >
    commit >  master上的提交
    commit <  dev上的提交

指定远程分支 origin/master 进行比较
查看远程master分支比本地dev分支多哪些内容

git log --left-right dev..origin/master

远程分支master与本地分支dev的提交差异

git log --left-right dev...origin/master

patch

git diff HEAD HEAD~1

git diff LongId LongId

git diff LongId LongId whichFile

为最后的commit生成patch

git format-patch -1

(oldCid, newCid)

git format-patch oldCid..newCid

[oldCid, newCid)

git format-patch oldCid~1..newCid

指定某个

git format-patch -1 cid

First the stats:

git apply --stat a_file.patch

Then a dry run to detect errors:

git apply --check a_file.patch
git apply fix.patch
git apply fix.diff

git apply --directory=amend/ fix.patch
posted @ 2023-09-04 18:52  fndefbwefsowpvqfx  阅读(10)  评论(0编辑  收藏  举报