简体   繁体   English

有没有办法在 Git 中获得这个 TFVC 功能?

[英]Is there a way to get this TFVC functionality in Git?

We are transitioning one of our .NET apps from using TFVC to Git.我们正在将我们的 .NET 应用程序之一从使用 TFVC 转换为 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.假设我在本地开发环境中,我想使用 QA 数据库。 I pull down a shelveset "Point dev at QA".我拉下了一个搁置的“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).这是通过搁置集完成的原因是代码库是旧的、继承的和单一的,并且连接字符串被引用(和使用)约 30 次,无法设置转换(本地开发都是自定义的)并托管在本地 IIS 站点上。应用程序本身是使用自定义 powershell 脚本构建的)。

Is there a way to do something similar to this in git?有没有办法在 git 中做类似的事情? Can I have like a floating commit, not in master, that I can yank in temporarily and undo?我可以像浮动提交一样,而不是在 master 中,我可以临时拉入并撤消吗? 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.请注意,我知道唯一可行的选择可能是修改代码库以接受某种环境设置、合并连接字符串等,但到目前为止,这是一个巨大的提升,我想知道是否有可能这样做而不必进行更改。

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).仅出于本地目的,您可以使用称为git stash的类似功能,它允许您以补丁的形式保存本地修改并提供一些有用的命令来应用此补丁(您可以拥有多个具有不同描述的补丁并随意应用它们 - 请参阅链接文档)。

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.如果更改集是有限且恒定的,则它可能是可编写脚本的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM