34

What is the concept of each?

When is it ok to shelve your changes instead of checking in?

juan
  • 80,295
  • 52
  • 162
  • 195

5 Answers5

37

Shelved means the changes are set aside for you to work on later.

Checked in means that the changes are made available to the rest of the team, will be in the build and will eventually ship.

Very different. Think of shelving as a tool for context switching when you're not done with a task. Checking in means you're done (at least a part of it).

Darcy Casselman
  • 2,574
  • 3
  • 24
  • 26
  • 1
    Imagine I shelve some stuff. Would my solution then build with my shelved changes or as if I didn't change anything? And, can I at some point unshelve the changes and continue to work on them? – chiapa Jan 27 '16 at 16:55
  • I appreciate this was answered some time ago but it isn't uncommon these days for shelvesets to be used by *other* developers as well. Some examples: 1) When code requires review for checkin (perhaps by more senior developers. 2) When work is incomplete and needs to be finished off by other developers but can't be checked in as it could break the build (in a CI scenario). – Robbie Dee Nov 29 '16 at 13:42
  • is shelve the same as git commit before push? – Neville Nazerane Dec 18 '17 at 07:39
12

Shelve your changes when you want to save the changes that you have made, but need to go back to the previous version to make other changes (perhaps, bug fixes) that you want to deploy without the updates you are currently working on. Since you're usually checking in pretty regularly, I find this to be a rare occurence -- like I just deployed to the QA box and an error was immediately found. I'll shelve that day's changes bringing me back to the QA deployed version, make the update, then unshelve my changes -- merging the two as necessary. Any longer than that and you'll probably be looking to check out a previous version and branch instead. I'd be happy to hear of other experiences where shelving has proved more useful, though.

tvanfosson
  • 524,688
  • 99
  • 697
  • 795
  • does this mean, that we can shelve our changes to make a separate version of our project? i'm currently working on a project, and i need to check it in, but again another checking with older version, since these two version are wholly different, and i switched to the old code, but also it's necessary since i may want to turn back to my new codes. can it be used for that? – Hassan Faghihi Aug 15 '16 at 10:17
6

Other users can download your shelvesets by searching for them, so it is a good way to pass code around for reviews. however you will get an error if you try to unshelve code files that you already have checked out, so you need a clean environment ready.

I often shelve my changes at the end of the day if I'm working on something big that I can't check in. That way, if my PC dies overnight, I've got a backup on the server.

cjk
  • 45,739
  • 9
  • 81
  • 112
3

Darcy gets it spot on. You can also think of shelving as a private branch that is not publicly visible for the most part. Shelvesets can also be deleted completely, not like deleting checked in code. If you delete a shelfset it is gone forever.

Ray Booysen
  • 28,894
  • 13
  • 84
  • 111
0

Everyone above has said so much true and I learned allot from it.

Just to add my experience, correct me if I am wrong. In a project, we have a configuration file mypc.json specific to each PC of the developer. We usually override it when running server locally. Other team members have the same file name with different configurations in it. No one wants their file to be pushed with the same name to the development branch. So I use shelve to save these type of changes. Whenever I need these configurations I can easily apply changes from shelve and my environment configurations are back in my project.