title | tags | |||
---|---|---|---|---|
How to See a `git diff` Between a Remote Branch and Your Local Branch |
|
Example: You're working locally on the dev
branch and before you start you want to check to make sure that you have the most updated version.
- Run a
git fetch
to fetch any new updates from the remote
$ git fetch
# example output
remote: Enumerating objects: 49, done.
remote: Counting objects: 100% (44/44), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 22 (delta 12), reused 19 (delta 10), pack-reused 0 (from 0)
Unpacking objects: 100% (22/22), 48.79 KiB | 832.00 KiB/s, done.
From github.com:serpcompany/serp-nuxt-template
384b705..153f709 dac/14/nuxt-seo -> origin/dac/14/nuxt-seo
* [new branch] dac/41/catch-all-routing -> origin/dac/41/catch-all-routing
c03b351..477f6a8 dev -> origin/dev
It pulled down some new branches, and some updates to the dev
branch we're working on.
- Run this
git diff
command to see the specific changes between the remotedev
branch and the local
# git diff <local-branch> <remote-name>/<remote-branch-name>
$ git diff dev origin/dev
And you'll see a diff:
git diff <local-branch> <remote-name>/<remote-branch-name>
- Considers the differences in content between the two branches, regardless of their relationship (whether one is ahead of the other).
- It does not take into account the common ancestor of the two branches; it's just a straight comparison of changes between the two tips (local dev and remote origin/dev).
For example: If dev has 3 new commits and origin/dev has 2 new commits, it will show the combined differences between both sets of changes.