user2761895
user2761895

Reputation: 1541

arc diff a branch which already pushed to remote by creating a new branch in git

This is a situation where I needed to do. I have a branch in my local, say testBranch (which contains a modified file file.txt). I've already pushed testBranch to remote by git push origin testBranch. So I cannot arc diff so that other people can review my code via Phabricator (since I already pushed)

What my co-worker did was create a new branch, say testBranch1 as follows:

git checkout testBranch
git merge master            // merge master to testBranch

git checkout master
git pull --rebase           // git pull while my local update reserved

git checkout testBranch
git merge master             // merge master to testBranch

git checkout master
git merge testBranch          // merge testBranch to master

git reset origin/master      // set the current HEAD to origin/master in my local
git checkout -b testBranch1
arc diff

Now others can review the modified file.txt in newBranch1 via Phabraicator. I have no idea what's going on and why this works. Could anyone explain why this works?

Upvotes: 0

Views: 3679

Answers (1)

CEPA
CEPA

Reputation: 2602

Arcanist (arc) is a pre-commit (a.k.a. pre-push) code review. Once the branch is pushed to origin, it has defeated the purpose of Arcanist. Once you have pushed, you have a few options:

  1. Delete the branch on origin with git push origin --delete testBranch.
  2. When running the arc diff command, tell it what you want to base it from like this: arc diff origin/master.
  3. Do the steps above, however, you should note, there is no git push on the above lines which is what is solving the issue.

Upvotes: 5

Related Questions