Git diff with remote tag
Solution 1
Most git commands only work locally, esp. things like git diff
and git merge
.
Your local repository can have multiple remotes, but in order to work on these, you must first sync the local repository with your remotes:
git fetch --all
While this will download all the changesets, it will not apply them to your current branch, unless the current branch is tracking one of the remotes.
Once you have downloaded the remote changesets and tags, you can simply run something like:
git diff tagged_idea
... and see the diff between your current HEAD
and a tag tagged_idea
, wherever the latter resides.
Solution 2
I use git ls-remote --tags proposal |grep tagged_idea
to get the revision hash, then do git diff
with the hash.
Related videos on Youtube
aspyct
Updated on September 20, 2022Comments
-
aspyct over 1 year
I'm about to merge a big change from a remote branch (non-origin), and more specifically from a given tag.
There are two remotes then:
origin
proposal
On the
proposal
remote, a branch nameidea
exists, with a tagtagged_idea
.The idea is that I want to review the incoming changes between
tagged_idea
and my current HEAD. How can I achieve this?I tried something like
git diff .../proposal/tags/tagged_idea
but it didn't work well. Any idea?In other terms, what I would like to see is the result of the merge, before even doing it in my branch. Just like if I did the pull
git pull proposal tags/tagged_idea
but without actually making the changes. -
torek over 10 yearsIf you use
git fetch
instead ofgit pull
, you'll still get all the new commits, but git will not attempt to merge (or rebase, depending onpull.rebase
and other git config settings) any of those changes even if you're on a "tracking" branch. (There's a minor caveat if you normally track a force-pushed remote branch and auto-rebase with the "smart" rebase thatgit pull --rebase
can do, but that's a very unusual work-flow.) -
DylanYoung over 4 yearsThis was the only solution that worked for me (the tags on the remote weren't fetched because the names matched the tags locally). Of course, the whole purpose of the diff was to see if there were any differences and where they came from: catch 22 ;)
-
ingyhere over 2 yearsThis does not work when you have local and remote tags with the same name. It only compares against the local tag.
-
ingyhere over 2 yearsThe hash definitively identifies the tag. Use
git show-ref --tags -d
to view local and remote tags. The local name should be followed by^{}
if there is a collision with an identically named tag.