Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the Git equivalent of TFS commands shelve/unshelve? cherry-pick?

Tags:

git

tfs

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.

like image 880
MatthieuGD Avatar asked Jun 18 '10 13:06

MatthieuGD


People also ask

What is shelve and Unshelve in TFS?

Unshelving is how you restore the shelveset to your machine so you can keep working on it. It doesn't change the shelveset on the server (to do that you need to shelve things again and use the same shelveset name).

What is shelving in git?

git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on.

What does Unshelve changes mean?

Unshelve changes Unshelving is moving postponed changes from a shelf to a pending changelist. Unshelved changes can be filtered out from view or removed from the shelf. In the Shelf tab, select the changelist or the files you want to unshelve.

Can we create Shelveset in git?

Shelvesets are just temporary branches. So - just make new branch. Branches in Git are very lightweight so creating, pushing and removing from server is very simple and fast. You can name it i.e. wip-blabla to notify that this is still unready.


1 Answers

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:

# do some stuff vim foo/bar.c # stash away your changes git stash  # do some other things...  # retrieve your changes git stash pop 

If you wanted someone else to have access to this changeset, you'd want to instead commit it to a working branch:

# make yourself a branch git checkout -b temp-featureA # commit to it git add foo/bar.c; git commit  # now you push this branch (or they could just fetch straight from you) git push origin temp-featureA   # Now, in someone else's repo: # Fetch updates git fetch origin # Make a branch tracking the remote branch git branch temp-featureA origin/temp-featureA  # Either check it out: git checkout temp-featureA # or cherry-pick it, to apply the changes somewhere else: git cherry-pick temp-featureA # or, if it's multiple commits, rebase it! git rebase --onto my-branch start-of-featureA temp-featureA 
like image 187
Cascabel Avatar answered Oct 21 '22 22:10

Cascabel