带有远程标签的 Git 差异
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19662570/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git diff with remote tag
提问by aspyct
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
origin
proposal
On the proposal
remote, a branch name idea
exists, with a tag tagged_idea
.
在proposal
遥控器上,idea
存在一个带有标记的分支名称tagged_idea
。
The idea is that I want to review the incoming changes between tagged_idea
and my current HEAD. How can I achieve this?
这个想法是我想查看tagged_idea
和当前 HEAD之间的传入更改。我怎样才能做到这一点?
I tried something like git diff .../proposal/tags/tagged_idea
but it didn't work well. Any idea?
我尝试了类似的东西,git diff .../proposal/tags/tagged_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.
换句话说,我想看到的是合并的结果,甚至在我的分支中执行之前。就像我做了拉动git pull proposal tags/tagged_idea
但没有实际进行更改一样。
回答by uml?ute
Most git commands only work locally, esp. things like git diff
and git merge
.
大多数 git 命令只能在本地工作,尤其是。像git diff
和这样的东西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 trackingone 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.
... 并查看当前HEAD
标签和标签之间的差异tagged_idea
,无论后者位于何处。
回答by Pluto
I use git ls-remote --tags proposal |grep tagged_idea
to get the revision hash, then do git diff
with the hash.
我git ls-remote --tags proposal |grep tagged_idea
用来获取修订哈希,然后git diff
使用哈希。
回答by Monir
Please do not use it, if you are only looking for a command because the main intention of this solution is to introduce you a way of solutions !
如果您只是在寻找命令,请不要使用它,因为此解决方案的主要目的是向您介绍一种解决方案!
To make life easier - i wrote a script git-cheat-sheet,that contains some useful commands , including the following:
为了让生活更轻松 - 我写了一个脚本git-cheat-sheet,其中包含一些有用的命令,包括以下内容:
./git_commands.sh -diff_tag
./git_commands.sh -diff_tag