Shelving a stash

459 views
Skip to first unread message

Nodir Turakulov

unread,
May 21, 2012, 11:54:47 AM5/21/12
to git...@googlegroups.com
I often have situations that I need to share some changes with a
co-worker without checking them in. With Git the obvious solution is
to make a remote branch and work there together. In case of TFS I use
shelvesets, an analog of Git stash, but stored on the server.

The next thing I'll do is adding support for shelvesets. Here is a
usage scenario:

1. You change code
2. Instead of "git stash" you run "git tf shelve <name>" (I doubt that
I'll make the shelveset name optional because "shelveset{n}" is not a
good name in TFS because shelvesets are not stacked as stashes, so
names won't be updated when shelvesets are pushed/popped)
3. git-tf checks the changed files out and shelves them (tf shelve
<name>) without undoing the changes.
4. git-tf stashes the changes, the stash has shelveset's name. Now the
changes are undone as a part of stashing.

When you need to unshelve, you can just apply a stash (git stash apply
<name>) without interacting with the server.
"git tf unshelve <name>" will delete the shelveset and pop the stash
of the specified name.

I'm not sure I will have to mark shelved stashes with git notes
(although it's possible) because the stash name equals the shelveset
name.

In the past I thought of shelving a branch, but decided to shelve a
stash because:
1. Branch is a pointer to a full tree version and you can make
multiple commits in a branch, while a shelveset, as a well as a stash,
contains only changed files, a single version thereof. When you
unshelve a shelveset, its changes are merged with commits made after
the shelveset was made. Stashes work the same way.
2. When I worked with TFS without git-tf, I always undone the shelved
changes. Stashes work the same way.
3. Stashing is just simpler than making a new branch.

If you have any comments or suggestions, I will be happy to hear them.

-Nodir
Reply all
Reply to author
Forward
0 new messages