2

I have a question about Git that I've never had to do, so I would like to learn!

In my project I branched off master a while back; it is essentially a rewrite of the entire codebase, so let's call it rewrite. In the time that I have been working on rewrite I have also made and deployed some significant changes to master. Now that my rewrite is coming to a close, I want to bring it up to speed with all the changes made on master since I started the branch.

Usually I would do something like git checkout rewrite && git rebase master and then solve the conflicts as they arise, but this time around I can guarantee every commit with have a conflict since the codebase is entirely different.

tl;dr What I am wondering is how I would go about taking each commit on master and one-by-one merging them into rewrite, so I could do it at my own pace and possibly out of order if need be.

Jody Heavener
  • 2,704
  • 5
  • 41
  • 70
  • Possible duplicate of [How to merge a specific commit in Git](https://stackoverflow.com/questions/881092/how-to-merge-a-specific-commit-in-git) – Inigo Apr 30 '18 at 20:39

1 Answers1

3

You can use git cherry-pick command to put specific commit to your branch.

You can also use gitk --all to see all commits and select which commit you want to cherry-pick interactively to your branch.

Slawomir Jaranowski
  • 7,381
  • 3
  • 25
  • 33
  • For some extra insurance, you can `git checkout rewrite && git checkout -b rewriteMerge` which will give you an identical branch to start and perform your cherry picking on. That way, if anything, at any point, goes awry, it's a little easier to get back to where you were. There are of course other methods (such as resets and later on creating a new branch based on the final `rewrite` commit shaVal), but this way gives you something tangible and accessible by simply changing branches. – tniles Apr 19 '16 at 20:52