Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,289
Community Members
 
Community Events
177
Community Groups

How to create a patch for a single (or selected) file?

I cannot seem to find a way to create a patch (or diff) for a subset of files for a commit.

Environment:

  • Sourcetree 2.6.3 (134) for Mac (OS X Sierra)
  • Git repository on BitBucket

Scenario:

  1. Large commit containing many changes
  2. In History View, I right click on the most recent commit and select "Create Patch..."
  3. Patch window appears.  In the history pane of the patch window I select the version I want to generate the diff (patch) from
  4. In the files window (lower left of the patch window) I select only the files for which I want to view
  5. This works for VIEWING the diffs (it only shows the diffs for the selected files) but when I click "Create" to create the patch file, the patch shows ALL files that have changed

How do I create a patch (diff) file for only the selected files?

2 answers

1 vote
Manju Atlassian Team Dec 22, 2017

I'm afraid there isn't an option to create patch per file or for individual files in commits. This is possible only if the changes are not committed. 

Feel free to submit an enhancement request on jira.atlassian.com for the Sourcetree team to consider this feature in a future release. 

Thanks,
Manjunath
Sourcetree Mac Developer

Hi Manju, how can it be done if the changes are not committed?
Should the file(s) be staged first?

As far as I know, this feature is still not implemented in the latest sourcetree version.

But, actually, what you want is possible when creating a patch file from your working copy changes. So there is a workaround by performing the following steps:

  1. You checkout the commit that is one commit ahead of your desired commit
  2. You Cherry Pick your changes from the desired commit (uncheck the check box "Commit immediately upon successful merge". No you have "load" the commit into your working copy.
  3. You click on Actions->Create Patch...
  4. You click on "Working Copy Changes"
  5. You can now select all files that should be included into the patch file

Step 1 may not be needed in every case, but may be helpful to avoid a lot of merge conflicts and to make sure that all changes of the desired commit are included in the patch file.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events