Skip to content

Instantly share code, notes, and snippets.

@nepsilon
Last active November 4, 2025 07:16
Show Gist options
  • Save nepsilon/22bc62a23f785716705c to your computer and use it in GitHub Desktop.
Save nepsilon/22bc62a23f785716705c to your computer and use it in GitHub Desktop.

Revisions

  1. nepsilon revised this gist Jul 8, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion how-to-git-patch-diff.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,8 @@ You think there must be a better way to proceed and you’re right. It’s a sim
    git diff > some-changes.patch
    ```

    **2\. Apply the dirr:**
    **2\. Apply the diff:**

    Then copy this patch to your local machine, and apply it to your local working copy with:
    ```bash
    git apply /path/to/some-changes.patch
  2. nepsilon revised this gist Jul 8, 2016. 2 changed files with 19 additions and 8 deletions.
    8 changes: 0 additions & 8 deletions git-path-diff.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +0,0 @@
    # Generate the patch:
    git diff > some-changes.patch
    # Copy this patch to your local machine

    # Apply the patch to your local working copy:
    git apply /path/to/some-changes.patch
    # And that’s it! The changes are now in your
    # working copy and ready to be staged/commit/pushed :)
    19 changes: 19 additions & 0 deletions how-to-git-patch-diff.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    # How to generate and apply patches with git?

    It sometimes happen you need change code on a machine from which you cannot push to the repo.
    You’re ready to copy/paste what `diff` outputs to your local working copy.

    You think there must be a better way to proceed and you’re right. It’s a simple 2 steps process:

    **1\. Generate the patch:**
    ```bash
    git diff > some-changes.patch
    ```

    **2\. Apply the dirr:**
    Then copy this patch to your local machine, and apply it to your local working copy with:
    ```bash
    git apply /path/to/some-changes.patch
    ```

    And that’s it! The changes are now in your working copy and ready to be staged/commit/pushed :)
  3. nepsilon revised this gist Feb 1, 2016. No changes.
  4. nepsilon created this gist Feb 1, 2016.
    8 changes: 8 additions & 0 deletions git-path-diff.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # Generate the patch:
    git diff > some-changes.patch
    # Copy this patch to your local machine

    # Apply the patch to your local working copy:
    git apply /path/to/some-changes.patch
    # And that’s it! The changes are now in your
    # working copy and ready to be staged/commit/pushed :)