Skip to content

Instantly share code, notes, and snippets.

@jonesmac
Created April 21, 2020 21:09
Show Gist options
  • Select an option

  • Save jonesmac/80bb45656cbcf9b02f15fa9e3e295fc9 to your computer and use it in GitHub Desktop.

Select an option

Save jonesmac/80bb45656cbcf9b02f15fa9e3e295fc9 to your computer and use it in GitHub Desktop.

Revisions

  1. jonesmac revised this gist Apr 21, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_rebase_--onto example.md
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ Assuming you have feature/124 checked out, you can use `git rebase --onto develo
    What's actually taking place when you run the command:

    1. set `develop` (currently at N) (arg 1) as the *new base branch* for your current branch - `feature/124`
    * --onto is saying reset `feature/124` `on to` `develop`'s tip
    * `--onto` is saying reset `feature/124` `on to` `develop`'s tip
    2. set `feature/123` (currently at I) (arg 2) as the starting point for the new commits
    * All changes made by commits in `feature/124` but that are not in `feature/123` (J, L, and M) are saved to a temporary area.
    3. replay the commits in the temporary area to branch `feature/124`
  2. jonesmac created this gist Apr 21, 2020.
    34 changes: 34 additions & 0 deletions git_rebase_--onto example.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    Given I have a setup like so
    ```
    A---B---C---D develop
    \
    E---F---G---H---I feature/123
    \
    J---L---M feature/124
    ```

    And feature/123 is squash merged (N) into develop leaving feature/124 with extra commits

    ```
    A---B---C---D---N develop
    \
    E---F---G---H---I feature/123
    \
    J---L---M feature/124
    ```

    Assuming you have feature/124 checked out, you can use `git rebase --onto develop feature/123` to end up with

    ```
    A---B---C---D---N develop
    \
    J---L---M feature/124
    ```

    What's actually taking place when you run the command:

    1. set `develop` (currently at N) (arg 1) as the *new base branch* for your current branch - `feature/124`
    * --onto is saying reset `feature/124` `on to` `develop`'s tip
    2. set `feature/123` (currently at I) (arg 2) as the starting point for the new commits
    * All changes made by commits in `feature/124` but that are not in `feature/123` (J, L, and M) are saved to a temporary area.
    3. replay the commits in the temporary area to branch `feature/124`