Jordan Savant # Software Engineer

Ever wanted to apply code changes committed in one file to a totally other file?

Create a patch file of the diff

    for unstaged:
        git diff HEAD^ -- path/to/filename.scala > my-patch-description.patch

    for staged:
        git diff HEAD^ --staged -- path/to/filename.scala > my-patch-description.patch

    for committed:
        git diff 89d5cc5 path/to/filename.scala > my-patch-description.patch

Apply the patch

patch -p1 path/to/target/file.scala my-patch-description.patch