Can you arc diff against a particular git branch?

By | January 4, 2018

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 docs are unclear on this. Is it possible? How? It would be nice if the answer works for 2-3 local un-pushed commits as well.

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.

Also, I’m happy to receive “you’re doing it wrong” answers if the answer explains how to do it right.


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.)

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 undo any commits on the branch which are descendants of the branch point, just like git diff <branch>..HEAD would.

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.

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.

See also:


Evan’s answer is generally preferable because it is more reflective of best git workflow practices. I recommend following that if you can.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *