Skip to content

Instantly share code, notes, and snippets.

@dkoslicki
Last active July 8, 2022 17:32
Show Gist options
  • Save dkoslicki/8830942a85d8ccf4f99da356fd5462c7 to your computer and use it in GitHub Desktop.
Save dkoslicki/8830942a85d8ccf4f99da356fd5462c7 to your computer and use it in GitHub Desktop.

Current state

(master) a -> b -> c
         |
(itrb)     -> d

Idea: Create a new branch from b, merge that into (test)

1. Go to the commit

git checkout (hash for commit b)

git checkout 32167235b8b1e4f874e901a265641d6c7fb01e33

2. Create a new branch off of this commit

git switch -c middle_branch

Current state:

(master) a -> b -> c
         |    |
         |     -> (middle_branch)
         |
(test)    -> d

3. Push this new branch:

git push --set-upstream origin middle_branch

4. Switch over to test branch

git checkout itrb_test

5. Merge from that middle branch, resolve conflicts, and push

git merge --no-ff origin/middle_branch

(resolve conflicts if any)

git push

Current state:

(master) a -> b -> c
         |    |
         |     -> (middle_branch)
         |       |         
(test)    --------> d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment