I found that the shelve/unshelve commands in TFS are very handy and very simple to use. What's the equivalent in Git ?
here's the scenario in TFS :
- I made changes in the trunk
- I shelve : the change set is saved on the server (with a label) and I get the source back before the changes
- I work in the trunk
- Someone can unshelve : get the change set in his workspace
I know that there's a command call cherry-pick but i"m not sure of the workflow and if it fits the need.
What you describe is similar to
git stash
, except since with git you have your own repository (not just a single one on a server), only you can get that change set back.The general idea is:
If you wanted someone else to have access to this changeset, you'd want to instead commit it to a working branch:
What you want to do is accomplished with plain old branching in git.
From a nice StackOverflow answer by JaredPar:
This is analogous to committing to a branch and pushing it to a server in git.
How to do it:
Let's say you're working on the "master" branch and you decide to implement feature X. You get a good start on it, but then your boss tells you that feature Y needs implemented as soon as possible. Phil in the next cube over volunteers to finish feature X while you do feature Y. Here's what you do:
Make a new branch and switch to it:
Commit your changes:
Push it to a server that Phil can see:
Go back to the master branch (which has not changed):
You might also want to proactively create a new branch for feature Y:
Phil can now pull down your feature X work and pick up where you left off:
git stash is a bit similar, except it is limited to your working tree.
In a DVCS, to achieve that kind of workflow, you need to:
Another way would be to let the other developer fetch your branch (where you have committed that special set of changes), and cherry-pick it, but that is not recommended, for cherry-picked commits are hard to track.