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 web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
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)