How can I reinstall as a single latch using git

My story looks something like this, but times 10:

                i - j - e'- k - h'- l - m  feature-branch
              /
    a - b - c - d - e - f - g - h  master

(apostrophes mean cherry pick) I want to reinstall this:

                                  i - j - k - l - m  feature-branch
                                 / 
    a - b - c - d - e - f - g - h  master

I do not mind if this function is crushed into 1 commit. The main problem with regular reboots is that it tries to reinstall one commit at a time, and I have to fix and fix such conflicts again and again.

All I want to do is accept the difference between the tip of my branch and the tip of the master and apply them to the top of the master.

+4
source share
2 answers

This is actually quite simple.

  • master feature-branch. . (I .)

                i - j - e'- k - h'- l - m - n    feature-branch
              /                           /
    a - b - c - d - e - f - g - h --------       master
    
  • git reset --soft master. , feature-branch master, , .

                i - j - e'- k - h'- l - m - n    (orphaned)
              /                           /
    a - b - c - d - e - f - g - h --------       master, feature-branch
                                  \
                                    (index)
    
  • git commit

                i - j - e'- k - h'- l - m - n    (orphaned)
              /                           /
    a - b - c - d - e - f - g - h --------       master
                                  \
                                    n'           feature-branch
    

# 2 # 3 - feature-branch. , , . , , .

+5

, e' h' e h, . , , Git e' h', . , , .

:

  • git rebase , e' h', git rebase --skip, Git .

    , , , :

    git reset --soft master
    git commit
    
  • Git e' h':

    git checkout feature-branch
    git rebase -i master
    # Git will launch an editor containing an interactive rebase recipe:
    #   1. Delete the e' and h' lines.
    #   2. Optionally change the j through m lines to 'squash' if you
    #      want to squash all of those commits into one.
    #   3. Save the recipe and exit.
    
  • git rebase - git cherry-pick. :

    git checkout -b temp-branch master
    git cherry-pick i j k l m
    # optionally, if you want to squash i through m into a single commit:
    #   git reset --soft master
    #   git commit
    git checkout feature-branch
    git reset --hard temp-branch
    git branch -D temp-branch
    
+2
source

All Articles