How can I cherry pick the files I want to shelve

I have 5 modified files. Two are modified to facilitate getting my local dev server going instead of for staging or production servers. Those I frequently need to shelve and unshelve as part of doing a Pull/Update. The other three are actual changes I may commit someday. 

How can I shelve the two files to one shelf and the other 3 files to another shelf and access either later using a name I choose?

Is this possible? If so, how?

1 answer

You should make use of Patch for the 2 files that you'll use often and doesn't need to be checked in. 

Once you have a patch, you can apply it as many number of time as possible in any branch. 

Shelves may not work the way you want on other branches.

This sounded like a good idea but when I created a patch file of the two files involved, discarded the changes to both files, then applied the patch file, both file contents were completely replaced instead of just the diff changes shown in the patch. Is this normal for patch files to replace the contents with modified content such that the top half the diff view shows pink "-" lines and the bottom half shows green "+" lines? When I complete a shelve operation in TortoiseHg it simply shows only the modified lines in pink/green, not the whole file content. One of my two files has 2 lines changed, the begin comment and end comment symbols (commenting a 10 line block of code.) Yet the patch shows it needed to replace all contents. 

Patches are ideally nothing but diffs. Have you tried ignore whitespace for the diff that you are seeing? 

Yes, that changed the diff view to show only the lines that changed! Thanks!

Why is there a difference? When I view the same diff but using an external Beyond Compare (which will show any whitespace diffs) it only sees the few lines that changed, not the whole file. It seems the default setting of Show whitespace option is not really showing correctly?

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

649 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you