patch

Applying branch changes to a new branch in git

Blog

I am unsure how other people do this, but this is how I apply changes from one branch to a new branch when the original branch can't be rebased to master (say, when the original branch is thousands, or really, maybe just hundreds or tens of conflicting, commits behind master).

$ git co branch-no-longer-loved

If differences with master aren't causing rebase issues, can do this:

$ git rebase master
$ git diff master > ~/some-differences.diff

More likely, I'm doing this because I can't rebase to master. So, taking my changes back to where I diverged from master, say 3 checkins:

$ git diff HEAD~3 > ~/some-differences.diff