0

Ok so I Have a branch in git that looks like this

A-B-C-D-E

and a branch that looks like this

A-B-F-G

I want to make a branch like this

A-B-D-E-F-G

I think tagging might be involved but I am rather new to git.

MrBrightside
  • 593
  • 2
  • 10
  • 22

2 Answers2

8

You may want to create a new branch, starting at commit B, and then cherry-pick the specific commits you're interested in onto your new branch.

git checkout my-branch <B-commit-id>

git cherry-pick <D-commit-id>
git cherry-pick <E-commit-id>
git cherry-pick <F-commit-id>
git cherry-pick <G-commit-id>
user229044
  • 232,980
  • 40
  • 330
  • 338
0

You may want to do a rebase on the other branch and an interactive rebase on commit B.

branchE points to Commit E. branchG points to Commit G

git checkout branchG
git rebase branchE
git rebase -i <B-commit-id>

Remove the complete line of C-Commit-Id. Save and close the editor. Finished.

Please read the help messages in the editor. It explains the possibilities of interactive rebase.