如何将本地git分支与其远程分支进行比较?

问题描述:

如何查看本地分支和远程分支之间的diff?

How can I see the diff between a local branch and a remote branch?

要更新远程跟踪分支,您需要先输入git fetch,然后输入:

To update remote-tracking branches, you need to type git fetch first and then :

git diff <masterbranch_path> <remotebranch_path>

您可以git branch -a列出所有分支(本地和远程),然后从列表中选择分支名称(只需从远程分支名称中删除remotes/.

You can git branch -a to list all branches (local and remote) then choose branch name from list (just remove remotes/ from remote branch name.

示例:git diff master origin/master(其中"master"是本地master分支,"origin/master"是远程即Origin和master分支.)

Example: git diff master origin/master (where "master" is local master branch and "origin/master" is a remote namely origin and master branch.)