Skip to content

Instantly share code, notes, and snippets.

@snggeng
Forked from zackdever/gist:8701478
Last active March 5, 2020 21:24
Show Gist options
  • Save snggeng/ce55df3b5a5401832ed1862da0e32659 to your computer and use it in GitHub Desktop.
Save snggeng/ce55df3b5a5401832ed1862da0e32659 to your computer and use it in GitHub Desktop.
arc diff off another diff
Topic: Dependent Phabricator reviews
Say you have an upstream called master, and a feature branch F1, and a second change that depends on F1, (call it F2).
git checkout master
git checkout -b F1
# work work
git commit -a
arc diff
git checkout -b F2 # Note that F1 is set as the upstream of F1
# set upstream, in this format git branch -u <remote>/<branch>
git branch -u F1
# work work
git commit -a
arc diff # arc will now check to see diffs against the upstream, so only the change from F1 to F2 will be posted
Now let's say you had issues in F1 from a review and you need to update the Phabricator diff.
git checkout F1
# fix the stuff
git commit -a --amend
arc diff # upload updated patch
git checkout F2
git rebase -i F1 # rebase the contents of F2 on top of the *new* F1. You should only select the actual change on F2
F1 has set its upstream to master. So let's say you want to land F1. After landing F1, you'll want to rebase F2 onto master and change its git upstream to master.
git checkout master
git pull origin master
git checkout F1
git rebase master
arc land --onto master # this lands F1. at this point, F2's upstream has disappeared. we need to fix that
git checkout F2
git branch --set-upstream-to=master # Now F2's upstream is master, since we landed F1!
git rebase -i master
Now, F2 is like a normal branch pointed to master. arc diff uses the upstream to determine the diff to upload to the server.
If you don't want to land F1, but want to update F1, you can do the same, but simply need to rebase F2 on F1 after updating F1's diff
git checkout F1
# work work
git commit -a
arc diff
git checkout F2
git rebase -i F1
A quick way to see what branches are dependent on each other is:
git branch -vv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment