Git Tip: Marking one change-set’s dependency on another

In this tutorial you will learn a commonly used feature of Git i.e. to mark a change-set’s dependency on another change-set. Consider following scenario:

  1. A change-set A is pushed for review
  2. Later, it is found to be dependent on a change-set B, which may already under review

In order to let Git take care of the dependency, following can be done:

  1. Checkout B and note down its <commit ID>
  2. Checkout A and run following command.

git rebase -i <commit ID>

This will open up an editor having a single line, prefixed with string: “pick”. No need to modify anything – Just save and close the editor.

Git will continue with the rebasing. You may have to resolve conflicts, if arise any. Finally, you can just push your code for review. If you use Gerrit Code Review system you may see, that “Depends On” field will start showing change-set B.

Subscribe: rss | email