Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating & applying patches #539

Closed
s3cur3 opened this issue Jul 11, 2019 · 5 comments
Closed

Support creating & applying patches #539

s3cur3 opened this issue Jul 11, 2019 · 5 comments

Comments

@s3cur3
Copy link

s3cur3 commented Jul 11, 2019

Problem description

A common workflow for transferring a work-in-progress between machines is to create a "patch" file on one machine, then apply it on another. As described in this Stack Overflow discussion, the way you'd do this from the command line is:

  1. $ git diff [--cached] [--binary] > mypatch.patch
  2. Transfer mypatch.patch to the other machine
  3. $ git apply mypatch.patch

This is different from #215, because the desire is to not have to create a commit (like git format-patch requires).

Preferred solution

I rather like the way SourceTree does this, where you enter the "create a patch" UI and can choose the files to be included in the patch, the destination, etc. Alternatively, a much simpler alternative would be Command Palette actions for:

  • "Create Patch from Staged Files"
  • "Create Patch from Unstaged Files"
  • "Apply Patch"

(each of which would take the path to the patch file)

Screenshots

Here's the UI SourceTree uses for choosing the files to include in a patch:

SourceTree Create Patch dialog

@sinapsist
Copy link

Does anybody know if there is an update on this issue? Is it on the roadmap?
JetBrains IDEs have it, and it is so useful. I wish Sublime would have it.

@JustSid
Copy link

JustSid commented Jun 22, 2022

I ended up making the following commands (save them in Defaults.sublime-commands inside the User packages folder:

    {
        "caption": "Create Patch",
        "command": "git",
        "args": {"argv": ["diff", "--cached", "--output", "$text"] }
    },
    {
        "caption": "Create Patch (unstaged)",
        "command": "git",
        "args": {"argv": ["diff", "--output", "$text"] }
    }
]```

I still wish there was a built-in way to do this better, but it does the trick for me

@dpjohnst
Copy link
Member

Hi all,

This has been added in Sublime Merge 2075 (development build), and will be added to the next stable build.

If you have any feedback, feel free to add to it here!

Cheers,
- Dylan

@JustSid
Copy link

JustSid commented Jul 28, 2022

@dpjohnst This is great, thanks. One question, maybe I'm just holding it wrong, but I can't seem to find a way to create a patch with multiple files? I can right click a file in the file browser and the file tab bar and then make an individual patch. Is there no way to select multiple files to create a patch and/or create a patch from the staged and/or unstaged changes?

@dpjohnst
Copy link
Member

Hi @JustSid,

Thanks for reaching out - currently we don't support multi-select for files.
That being said, you can save the modified/staged files section as a patch via the context menu for that section (accessible in the Files tab).

Kind regards,
- Dylan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants