سؤال

I currently have the following situation (simplified).

   master            C --+-- E
                     |   |   |
   hotfix            |   D --+
                     |       |
  develop    A - B - C ----- F - G - H - I
                                     |
  feature                            + J - K - L

I want to end up with:

   master            C --+-- E ------+
                     |   |   |       |
   hotfix            |   D --+       |
                     |       |       |
  develop    A - B - C ----- F - G - | --- H - I
                                     |
  feature                            + J - K - L

How would I go about doing this in a decent git-way? Everything in feature is non-dependend on G, since everything that's editted on feature is simply in a seperate folder.

I've tried the following (while on feature), but all these seem to leave traces of commits after F in feature:

 1. git rebase --onto master develop feature
 2. git rebase --onto E J~1
 3. git rebase --onto master develop
هل كانت مفيدة؟

المحلول 2

Since I could not wait any longer for a thorough solution, I decided to use the cherrypick suggestions. Though, I did not want to go ahead and cherrypick straight on the master branch, that would be bad practice in my git flow workflow. So I did the following:

  1. Start a new hotfix

    $ git flow hotfix start vx.x.x
    
  2. Cherry-pick the commits from feature

    $ git cherry-pick J^..L
    
  3. Finish the hotfix, essentially merging the cherry-picked commits into master and develop

    $ git flow hotfix finish vx.x.x
    
  4. Make sure I never get to merge the commits from the old feature branch by deleting them locally and potentially on origin.

    $ git branch -d feature
    $ git push origin :feature
    

So, after this, I got the following:

master            C --+-- E --+---------- O
                  |   |   |   |           |
hotfix            |   D --+   J - K - L --+
                  |       |               |
develop   A - B - C ----- F - G - H - I - M

I'm still convinced I should've been able to solve this somewhat more elegantly with rebase, but I think this did the trick on a marginally elegant way.

نصائح أخرى

Cherry pick J,K,L from feature onto master branch. You should use a good branching strategy in the future. I'm using this one and it works pretty well.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top