2019年10月30日 星期三

Working while waiting for pending PR

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)
    |\
    | *
    | *
    |/
    *
    *
    *
    
  • 5
    What happens if the first branch is rejected? – Narayon Dec 21 '16 at 10:46
  • 4
    I'd usually rebase user_story_2 onto mastergit rebase --onto master user_story_1 user_story_2 -- might result in conflicts if the two branches aren't completely independent. – alextercete Dec 22 '16 at 16:36 
  • I will give this a try – anquegi Jul 26 '18 at 15:01
  • 1
    For step 6, using interactive rebasing makes things easier. Try git rebase -i master, and it should show you a list of commits on user_story_2 including the earlier commits from user_story_1. Remove the pick lines for commits from user_story_1, and complete the rebase. – Athyuttam Eleti Feb 25 at 18:00
  • What if we need to update, add some commit in user_story_1? I guess after that we checkout to user_story_2 and rebase with user_story_1 ? – truongnm Jun 19 at 9:32
  • That's right (assuming user_story_1 hasn't been merged to master yet). – alextercete Jun 25 at 8:07
  • Yes of course! :)))) – truongnm Jun 26 at 10:57
  • What if I wanted to do the reverse i.e. user_story_1 would depend on user_story_2? Let me explain: I forked a project and created a PR from my develop branch to theirs. They requested a few changes and I made it, but then wanted more changes outside the scope of the PR that I made, specifically to refactor some of their core classes so that my PR fits better in the project. So now I have to make a new PR2 which creates a few generic classes and then make a new commit to my PR1 to incorporate those new generic classes. How would I go about doing these? – Saifur Rahman Mohsin yesterday

from : https://stackoverflow.com/questions/35790561/working-while-waiting-for-pending-pr