Reputation: 411
We are transitioning one of our .NET apps from using TFVC to Git. One practice we have now is the use of shelve sets to point our local development environments at different database, for example.
Say I am in my local dev environment, and I want to use the QA database. I pull down a shelveset "Point dev at QA". This will make the appropriate connection string swap for me. When I am done, I just undo the changes from the shelveset and check in my code.
The reason this is done via a shelveset, is that the code base is old, inherited, and monolithic, and the connection strings are referenced (and used) ~30 times, with no ability to set up a transform (local development is all custom and hosted on a local IIS site. The app itself is built with a custom powershell script).
Is there a way to do something similar to this in git? Can I have like a floating commit, not in master, that I can yank in temporarily and undo? I suppose I am just describing a shelveset though. Or make the changes on some remote branch that I temporarily merge with when I need to change environments?
Please note that I understand that the only viable option may be to modify the code base to accept some sort of environmental setting, consolidate connection strings, etc., but as of now that is a huge lift and I was wondering if it was possible to do so without having to make that change.
Upvotes: 0
Views: 42
Reputation: 7421
For local only purposes you can use similar feature called git stash
that allows you to save local modifications away in form of patch and provides some useful commands to apply this patch back (you can have multiple patches with different descriptions and apply them at will - see linked documentation).
Workflow then would be something like:
git checkout master
# point project towards QA env...
git stash push -m "qa-env-patch"
# now you should have master back
git stash list
stash@{0}: On master: qa-env-patch
...
git checkout dev.mybranch
# develop, develop, develop
git commit -a
# now ready to test, apply patch from stash
git stash apply 0
# fix bugs
git commit /only/files/or/chunks/that/have/nothing/to/do/with/qa/env
# done and happy, remove qa patch and put it back to stash
git stash push -m "qa-env-patch"
...
If you require something remote I'd use a branch and merge it to feature branch and then after job is done undo that commit before merging back to master. If set of changes is limited and constant it would be probably scriptable.
Upvotes: 1