您可以针对特定的 git 分支进行比较吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19819252/
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
Can you arc diff against a particular git branch?
提问by Will
I'm pretty new to both Arcanist and git. I'd like to be able to create an arc diff (Phabricator Differential instance using Arcanist) against a git branch that I'm currently checked-out/working in (and I have one local un-pushed commit) rather than the master. To me the arc docsare unclear on this. Is it possible? How? It would be nice if the answer works for 2-3 local un-pushed commits as well.
我对 Arcanist 和 git 都很陌生。我希望能够针对我目前正在检出/工作的 git 分支(并且我有一个本地未推送的提交)而不是主分支创建一个 arc diff(使用 Arcanist 的 Phabricator 差异实例)。对我来说,arc 文档对此不清楚。是否可以?如何?如果答案也适用于 2-3 个本地未推送提交,那就太好了。
Also "arc help diff" gives:
“弧形帮助差异”还给出:
diff [paths] (svn)
diff [commit] (git, hg)
Supports: git, svn, hg
Generate a Differential diff or revision from local changes.
Under git, you can specify a commit (like HEAD^^^ or master)
and Differential will generate a diff against the merge base of that
commit and HEAD.
Maybe I just need to do "arc diff [commit]" where [commit] is the tip of the target branch? But I'd like to be certain, because I don't want to pollute our Phabricator instance.
也许我只需要执行“arc diff [commit]”,其中 [commit] 是目标分支的尖端?但我想确定,因为我不想污染我们的 Phabricator 实例。
Also, I'm happy to receive "you're doing it wrong" answers if the answer explains how to do it right.
另外,如果答案解释了如何正确做,我很高兴收到“你做错了”的答案。
回答by Evan Priestley
In general, arc diff <branch>
will do what you want. (If you're already on the branch, rather than a local topic branch, try arc diff origin/<branch>
instead.)
一般来说,arc diff <branch>
会做你想做的。(如果您已经在分支上,而不是本地主题分支,请尝试arc diff origin/<branch>
。)
When invoked like this, arc
will actually diff against the merge-base
of the branch's tip and the current commit in the working copy, but generally this is what you intend. If you really want to generate a diff against the branch tip you can use arc diff --base git:<branch>
, but this diff will include changes which undoany commits on the branch
which are descendants of the branch point, just like git diff <branch>..HEAD
would.
当像这样调用时,arc
实际上会merge-base
与分支的提示和工作副本中的当前提交不同,但通常这就是您的意图。如果你真的想针对分支提示生成一个差异,你可以使用arc diff --base git:<branch>
,但是这个差异将包括撤销任何提交的更改,这些更改branch
是分支点的后代,就像git diff <branch>..HEAD
会一样。
In all cases, you can use arc which <commit>
to preview what arc diff
will do. This will explain which revision range would be selected, show you the command to see exactly which changes are included, and explain why that range is selected.
在所有情况下,您都可以使用arc which <commit>
来预览arc diff
将要执行的操作。这将解释将选择哪个修订范围,向您显示命令以准确查看包含哪些更改,并解释选择该范围的原因。
You can also use arc diff --preview
to generate just a diff, without sending it for review. This will let you preview changes before submitting them to anyone else.
您还可以使用arc diff --preview
仅生成差异,而无需将其发送以供审核。这将让您在将更改提交给其他人之前预览更改。
See also:
也可以看看:
https://secure.phabricator.com/book/phabricator/article/arcanist_commit_ranges/
https://secure.phabricator.com/book/phabricator/article/arcanist_commit_ranges/
回答by Will
Evan's answer is generally preferable because it is more reflective of best git workflow practices. I recommend following that if you can.
Evan 的答案通常更可取,因为它更能反映最佳 git 工作流程实践。如果可以,我建议遵循。
If you need a quick fix and are working in (checked out) the same branch that you want to push to, you can also do arc diff HEAD^
or HEAD~
for a single commit, or arc diff HEAD~N
for N commits.
如果您需要快速修复并且正在(签出)要推送到的同一分支中工作,您还可以执行arc diff HEAD^
或HEAD~
单个提交,或arc diff HEAD~N
N 次提交。