Skip to main content
added 477 characters in body
Source Link
AnoE
  • 5.9k
  • 1
  • 16
  • 17

Hold on, skip merging

For this approach, you do not want to merge your feature_a into feature_b repeatedly.

Rebasing has been mentioned in other answers, but only for rebasing things onto master. What you want to do in your case is:

  • Start your feature_b from feature_a, i.e.:

     git checkout feature_a git checkout -b feature_b 
  • Whenever feature_a changes while it is waiting to get merged into master, you rebase feature_b on it:

     ... commit something onto feature_a ... git checkout feature_b git rebase feature_a 
  • Finally, as soon as feature_a has been merged into master, you simply get the new master and rebase feature_aonto it a last time:

     git checkout master git pull origin master git checkout feature_b git rebase --onto master feature_a feature_b 

This final rebase will graft all commits that are dangling from the feature_acommit (which is now irrelevant as it has been merged into master) right onto master. Your feature_b is now a simple, standard branch going right from master.

EDIT: inspired from the comments, a little heads up: if you need to make some change which affects both features, then be sure to make it in feature_a (and then rebase as shown). Do not make it in two different commits in both branches, even if may be tempting; as feature_a is part of the history of feature_b, having the single change in two different commits will be semantically wrong and possibly lead to conflicts or "resurrections" of unwanted code, later.

Hold on, skip merging

For this approach, you do not want to merge your feature_a into feature_b repeatedly.

Rebasing has been mentioned in other answers, but only for rebasing things onto master. What you want to do in your case is:

  • Start your feature_b from feature_a, i.e.:

     git checkout feature_a git checkout -b feature_b 
  • Whenever feature_a changes while it is waiting to get merged into master, you rebase feature_b on it:

     ... commit something onto feature_a ... git checkout feature_b git rebase feature_a 
  • Finally, as soon as feature_a has been merged into master, you simply get the new master and rebase feature_aonto it a last time:

     git checkout master git pull origin master git checkout feature_b git rebase --onto master feature_a feature_b 

This final rebase will graft all commits that are dangling from the feature_acommit (which is now irrelevant as it has been merged into master) right onto master. Your feature_b is now a simple, standard branch going right from master.

Hold on, skip merging

For this approach, you do not want to merge your feature_a into feature_b repeatedly.

Rebasing has been mentioned in other answers, but only for rebasing things onto master. What you want to do in your case is:

  • Start your feature_b from feature_a, i.e.:

     git checkout feature_a git checkout -b feature_b 
  • Whenever feature_a changes while it is waiting to get merged into master, you rebase feature_b on it:

     ... commit something onto feature_a ... git checkout feature_b git rebase feature_a 
  • Finally, as soon as feature_a has been merged into master, you simply get the new master and rebase feature_aonto it a last time:

     git checkout master git pull origin master git checkout feature_b git rebase --onto master feature_a feature_b 

This final rebase will graft all commits that are dangling from the feature_acommit (which is now irrelevant as it has been merged into master) right onto master. Your feature_b is now a simple, standard branch going right from master.

EDIT: inspired from the comments, a little heads up: if you need to make some change which affects both features, then be sure to make it in feature_a (and then rebase as shown). Do not make it in two different commits in both branches, even if may be tempting; as feature_a is part of the history of feature_b, having the single change in two different commits will be semantically wrong and possibly lead to conflicts or "resurrections" of unwanted code, later.

Source Link
AnoE
  • 5.9k
  • 1
  • 16
  • 17

Hold on, skip merging

For this approach, you do not want to merge your feature_a into feature_b repeatedly.

Rebasing has been mentioned in other answers, but only for rebasing things onto master. What you want to do in your case is:

  • Start your feature_b from feature_a, i.e.:

     git checkout feature_a git checkout -b feature_b 
  • Whenever feature_a changes while it is waiting to get merged into master, you rebase feature_b on it:

     ... commit something onto feature_a ... git checkout feature_b git rebase feature_a 
  • Finally, as soon as feature_a has been merged into master, you simply get the new master and rebase feature_aonto it a last time:

     git checkout master git pull origin master git checkout feature_b git rebase --onto master feature_a feature_b 

This final rebase will graft all commits that are dangling from the feature_acommit (which is now irrelevant as it has been merged into master) right onto master. Your feature_b is now a simple, standard branch going right from master.