How can I see the diff
between a local branch and a remote branch?
You can use git rev-list . Simply call git rev-list feature_branch... origin/feature_branch (symmetric difference). If there is no output, both commits are the same.
1 Answer. There is a command that gives you about all tracking branches. And to know about the pull and push configuration per branch you can use the command git remote show origin. and you can use -sb option for seeing the upstream.
git diff <local branch> <remote>/<remote branch>
For example, git diff main origin/main
, or git diff featureA origin/next
Of course to have said remote-tracking branch you need to git fetch
first; and you need it to have up-to-date information about branches in the remote repository.
To update remote-tracking branches, you need to type git fetch
first and then:
git diff <mainbranch_path> <remotebranch_path>
You can git branch -a
to list all branches (local and remote) and then choose the branch name from the list (just remove remotes/
from the remote branch name.
Example: git diff main origin/main
(where "main" is the local main branch and "origin/main" is a remote, namely the origin and main branch.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With