RoninDev
RoninDev

Reputation: 5666

IntelliJ IDEA create patch from difference

I have IntelliJ IDEA Ultimate 2018.2.3. I am trying to create a patch from a difference (Compare with...) in IDE, but I can not find a button to do so. I have several commits on branch_A already. I do not need to create a patch from local changes, I need to create the patch from difference with another branch.

In git it simple git diff branch_A branch_B >> diff.patch

Is there any way to achieve it in the IDE?

Upvotes: 12

Views: 14328

Answers (4)

Lukasz Frankowski
Lukasz Frankowski

Reputation: 3175

Merge your branch with changes to source branch using VCS -> Git -> Merge changes with Squash commit option. After merge no commit will be done, but you will see changes in a single Changelist. You can click on this Changelist with right mouse button and select Create Patch from local changes option to export patch file. Then you can just revert.

Upvotes: 3

ivankolyada
ivankolyada

Reputation: 166

In IntelliJ IDEA 2020.2 I was able to make it like this:

  1. Make sure you have no current local changes beforehand: commit them or put them to stash.
  2. VCS -> Git -> Branches -> [select branch to compare with] -> Show Diff with Working Tree
  3. [in opened difference view select needed files] -> [right mouse button] -> Get from Branch
  4. VCS -> Create Patch from Local Changes...

Upvotes: 15

Jo Kachikaran
Jo Kachikaran

Reputation: 582

Here's how to do it on IntelliJ 2020.1.3

  1. Commit all you work in your current branch (say, my-committed-branch)
  2. Check out the branch against which you want to generate the diff as a patch (say, master)
  3. Create a new branch from the base i.e. master as say my-uncommitted-branch
  4. Go to VCS -> Git -> Checkout files from branch and choose my-committed-branch. It will show the list of files you have changed. Select all and click ok. You will now have all your changes as uncommitted changes
  5. Now select VCS -> Create Patch from local changes

Upvotes: 1

Peter Halligan
Peter Halligan

Reputation: 692

You can create a patch in the commit changes dialog.
1. go to local changes in version control and press ctrl+k to invoke commit dialog
2. fill in the required fields and then instead of pressing the commit button there is a dropdown arrow next to commit that you can select to create a patch.

https://www.jetbrains.com/help/idea/commit-and-push-changes.html#invoke-commit-dialog

Upvotes: 1

Related Questions