【发布时间】:2019-04-10 08:57:57
【问题描述】:
我们刚刚从 TFVC 迁移到 Git,马上就遇到了一个问题——如何挑选 TFVC 提交到 Git?
给定
- TFVC 分支
$/Alice - TFVC 分支
$/Bob - 带有
$/Alice的Git 存储库迁移为alice分支和$/Bob- 作为bob分支。 - TFVC 历史未迁移,因此“$/Alice”的整个 TFVC 历史只是一次 Git 提交。
$\Bob也是如此。
问题
现在我们在 $/Alice 中发现了一个 TFVC 提交,它在迁移之前没有合并到 $/Bob。现在在迁移之后,我们意识到我们需要将它放在bob 分支中。大败笔。
我说的是一个很大的变化——很多文件。因此,手动区分文件并复制更改不是很可行。我需要尽可能地自动化这个过程。
到目前为止我做了什么
我想我应该为有问题的 TFVC 变更集创建一个补丁。所以,这里是代码(假设我需要挑选提交 123):
$files = (tf changeset /noprompt 123 | sls '\$/') -replace '^[^$]+',''
$files |% { tf diff /version:C122~C123 /format:unified $_ } >> 123.diff
(我一个一个文件一个文件来做,因为它比使用/r标志运行tf diff要快得多)
无论如何,我得到一个像这样的补丁文件:
File: BackgroundJobTests\BackgroundJobTests.csproj
===================================================================
--- Server: BackgroundJobTests.csproj;115493
+++ Server: BackgroundJobTests.csproj;389742
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
===================================================================
File: BI\a8i\a8i.csproj
===================================================================
--- Server: a8i.csproj;342293
+++ Server: a8i.csproj;389742
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
...
一个典型的 Git 存储补丁看起来有点不同:
diff --git a/Yogi.txt b/Yogi.txt
index 056fd9e..1f73d44 100644
--- a/Yogi.txt
+++ b/Yogi.txt
@@ -1 +1 @@
-yaba daba do
+yaba daba doo
diff --git a/hello.txt b/hello.txt
index ce01362..980a0d5 100644
--- a/hello.txt
+++ b/hello.txt
@@ -1 +1 @@
-hello
+Hello World!
我觉得我需要一些指导。也许我做错了,有一个现成的解决方案可以解决我的痛苦。或者也许我的方向是正确的,我所需要的只是一种“欺骗”Git 接受我的补丁作为隐藏补丁的方法。但魔鬼在细节中,我缺少它们。
【问题讨论】:
标签: git migration tfvc cherry-pick git-cherry-pick