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

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

答案

git diff <local branch> <remote>/<remote branch>
git diff <masterbranch_path> <remotebranch_path>
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
git diff @{upstream}

我对以下内容的输出了解得更好:

git diff <remote-tracking branch> <local branch>

如果我按下本地分支,那会告诉我要删除的内容和要添加的内容。当然是一样的,只是反过来,但对我来说更具可读性,并且我更乐意观察即将发生的事情。

git fetch
git log -p HEAD..FETCH_HEAD
#To update your local.
git fetch --all
#to list all branches
git branch -a
#to go to the branch you want to check difference
git checkout <branch_name>
#to check on which branch you are in, use
git branch
    (or)
git status
git diff origin/<branch_name>

让您的工作分支是开发部门,并想区分本地开发分支机构和远程开发分支机构,在这种情况下,语法应类似于git diff remotes/origin/development..development
要么

git fetch origin git diff origin/development

$ git branch -a  # (or git branch --all) 
* my-branch
  master
  remotes/origin/some-branch
  remotes/origin/HEAD -> origin/master
  remotes/origin/my-branch
  remotes/origin/some-other-branch
  remotes/origin/master
$ git branch -r # (or git branch --remotes)
  origin/some-branch
  origin/HEAD -> origin/master
  origin/my-branch
  origin/some-other-branch
  origin/master
$ git branch
* my-branch 
  master
$ git branch --list 'my*'
* my-branch
# this will show all branches (local & remote) that start with my
$ git branch --list 'my*' -a
* my-branch

# better: the pattern includes the remote
$ git branch --list '*my*' -a
* my-branch
  remotes/origin/my-branch
$ git diff my-branch remotes/origin/my-branch
$ git diff my-branch remotes/origin/master
diff --git a/src/controllers/call.controller.js b/src/controllers/call.controller.js
index fd79b98..df3d798 100644
--- a/src/controllers/call.controller.js
+++ b/src/controllers/call.controller.js
@@ -261,7 +261,7 @@ function callController() {
   /*
    *  Function: doCall
[ . . . ]

如果您只想更改文件名就可以看到区别,请使用:

git diff --name-status <remote-branch> <local-branch>

否则,这将显示两个分支之间的所有差异:

git diff <remote-branch> <local-branch>