Skip to content

Instantly share code, notes, and snippets.

@gyliu513
Created October 13, 2015 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyliu513/ba654b791ef7fed7d77e to your computer and use it in GitHub Desktop.
Save gyliu513/ba654b791ef7fed7d77e to your computer and use it in GitHub Desktop.
Add Dependency
Add dependency
When you want to start new work that is based on the commit under the review, you can add the commit as a dependency.
#fetch change under review and check out branch based on that change.
git review -d $PARENT_CHANGE_NUMBER
git checkout -b $DEV_TOPIC_BRANCH
# Edit files, add files to git
git commit
git review
NOTE: git review rebases the existing change (the dependency) and the new commit if there is a conflict against the branch they are being proposed to. Typically this is desired behavior as merging cannot happen until these conflicts are resolved. If you don't want to deal with new patchsets in the existing change immediately you can pass the -R option to git review in the last step above to prevent rebasing. This requires future rebasing to resolve conflicts.
If the commit your work depends on is updated, and you need to get the latest patch from the depended commit, you can do the following.
git branch -D xxxx
# fetch and checkout the parent change
git review -d $PARENT_CHANGE_NUMBER
# Note the branch created by git review. Should be review/$USER/$PARENT_CHANGE_ID or similar.
# Checkout existing development topic branch for the child commit.
git checkout $DEV_TOPIC_BRANCH
# Rebase onto updated parent branch to create a dependency on the latest version of that change.
git rebase -i review/$USER/$PARENT_CHANGE #This is the branch created by git review that was noted earlier.
# Do the revisions
git commit -a --amend
# submit for review
git review
The note for the previous example applies here as well. Typically you want the rebase behavior in git review. If you would rather postpone resolving merge conflicts you can use git review -R as the last step above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment