Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working while waiting for pending PR

I'm working on a project and I submitted my first pull request and while I'm waiting I want to continue on working on my project building up from what I worked on the merge that's still pending on. Right now I have :

*master
user_story_1

user_story_1 has an open pull request.

Now I'm trying to create a new branch user_story_2 where I can continue the work I left of at user_story_1. How can I do this in Git without getting into any conflict or affecting my pending merge?

like image 250
Miguel Angel Quintana Avatar asked Mar 04 '16 07:03

Miguel Angel Quintana


2 Answers

I'm assuming you want to start the new user_story_2 branch on top of the work you've done in user_story_1. Here's the workflow I use in this sort of scenario:

  1. Open Pull Request for user_story_1:

      * (user_story_1)   *  / * (master) * * 
  2. Create new branch user_story_2 based on user_story_1:

    $ git checkout -b user_story_2 user_story_1
      * (user_story_1, user_story_2)   *  / * (master) * * 
  3. Work on the new branch:

      * (user_story_2)   *         * (user_story_1)   *  / * (master) * * 
  4. Pull Request gets merged:

      * (user_story_2)   *       * | (master) |\| | * (user_story_1) | * |/ * * * 
  5. Delete old branch:

      * (user_story_2)   *       * | (master) |\| | * | * |/ * * * 
  6. Rebase new branch onto master:

      * (user_story_2)   *        / * (master) |\ | * | * |/ * * * 
like image 115
alextercete Avatar answered Sep 20 '22 00:09

alextercete


My preferred workflow for this:

  1. On branch master, git checkout -b user_story_1.
  2. Make changes to user_story_1.
  3. Open PR for user_story_1.
  4. On branch user_story_1, git checkout -b user_story_2.
  5. Make changes to user_story_2.
  6. Once user_story_1 gets merged into master, switch to user_story_2 and do git rebase -i master.
  7. This should show you a list of commits on user_story_2 that you want to include in the rebase. Delete the top few commits that came from user_story_1.
  8. The rebase should complete cleanly unless master was updated with other changes. Now you have user_story_2 rebased on master and only having its commits.
like image 43
Athyuttam Eleti Avatar answered Sep 24 '22 00:09

Athyuttam Eleti