Read more

Git: Apply a diff

Emanuel
July 02, 2019Software engineer at makandra GmbH

git apply allows you to apply a diff onto your HEAD. Most often you can achieve the same result with a rebase & merge.

Illustration online protection

Rails professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
Read more Show archive.org snapshot

Example:

master                commit1 - commit3
feature-branch                \ commit2 - commit4
git checkout feature-branch
git reset --hard commit3
git diff ..commit4 | git apply
master                commit1 - commit3
feature-branch                          \ Unstaged commit 2 & 4

You can also create a patch and apply it afterwards.

Posted by Emanuel to makandra dev (2019-07-02 11:57)