Shelving enables you to store local changes in a personal stream in a repository and optionally remove the changes from a work area. You can use shelving to:
Shelve changes and reset a work area
You can remove changes from a work area that you do not want to deliver to the associated stream when:
The changes are not stable or complete.
You need to interrupt your current work and set aside the changes.
You need to switch to a different task but want to use the same work area rather than populate a new one, which can be time consuming.
After the shelving operation is complete you reset the work area to the latest repository content.
Backup changes
When you are sharing a stream with other developers but are not ready to deliver your local changes, you can backup your work by committing it to a personal stream. This creates a snapshot of the work area at that point in time. When creating backups you keep the local changes and do not need to reset the work area.
When you are ready to resume work on the shelved changes you can restore them by merging the personal stream back into the work area.
Typical shelving scenario:
Your team lead asks you to improve functionality in the next release of an application.
You download the tip of the stream to a local work area and begin work. Over the course of the next few days you create new files and modify existing ones.
Your manager asks you to interrupt your work and fix a very high priority bug that affects the same functional area. The fix requires you to modify some of the files that you recently changed. To avoid conflicts between the recent changes and the bug fix, and to use the same work area, you shelve your work to a personal stream and reset your work area to the latest repository content. You now have a clean work area that does not contain the changes you previously made.
You fix the bug and deliver the changes to the stream.
Your manager asks you to resume work on improving the functionality so you:
Merge the shelved content from the personal stream back into the work area.
Resolve any conflicts between the changes made for the bug fix and new feature.