git diff <local branch> <remote>/<remote branch>
例如git diff master origin/master
,或git diff featureA origin/next
当然, 曾经说过,你需要远程跟踪分支 git fetch
第一; 并且您需要它以获得有关远程存储库中分支的最新信息。
要更新远程跟踪分支,您需要先键入git fetch
然后:
git diff <masterbranch_path> <remotebranch_path>
你可以git branch -a
列出所有分支机构(本地和远程)然后选择分支的名字从名单(只是删除remotes/
远程分支的名字。
示例: git diff master origin/master
(其中 “master” 是本地主分支,“origin / master” 是远程,即 origin 和 master 分支。)
第一种
git branch -a
获取可用分支列表。在输出上你可能会看到类似的东西
* master
remotes/main/master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/mt
remotes/upstream/master
remotes/upstream/mt
然后显示差异
git diff --stat --color remotes/main/master..origin/master
git diff remotes/main/master..origin/master