mrt*_*181 2 git git-svn filter gitattributes
我正在使用Visual Studio 2010和git(git svn).我的同事使用纯svn和Ankhsvn插件.
当我尝试在启用Git源代码控制提供程序的情况下打开文件时,Visual Studion会抱怨:
源控制插件
活动解决方案或项目由与您选择的插件相关的源控制插件控制.如果更改源控件插件,将关闭活动解决方案或项目.
你想继续吗?
当我单击是时,将打开一个空的解决方案.当我单击否时,解决方案项旁边的所有git特定图标都会丢失(我仍然会在解决方案资源管理器中看到分支名称),每次打开解决方案时都会收到有关源控件插件的提示.
当我克隆我的同事创建的svn存储库时,解决方案sln文件包含以下内容
GlobalSection(SubversionScc)= preSolution
Svn-Managed = True
Manager = AnkhSVN - 对Visual Studio
EndGlobalSection的 Subversion支持
我已经删除了这一部分,现在解决方案在Git源代码控制提供程序被激活时没有问题,但是当您选择Ankhsvn提供程序时会抱怨 - 情况正好相反.
我想告诉git在pull(git svn fetch)期间删除.sln文件的这一部分,并在我提交时添加它(git svn dcommit).这可能通过gitattributes以及如何做到这一点?
编辑:
我现在补充说
solutionname.sln filter = ankhsvn
到$ GIT_DIR/info/attributes
和
[filter "ankhsvn"]
clean=sed '/^Global$/ r ../ankhsvnsection '
smudge=sed '/GlobalSection(SubversionScc)/,/EndGlobalSection/d '
Run Code Online (Sandbox Code Playgroud)
到我的.git/config文件.
ankhsvnsection包含由涂抹操作删除的部分.我似乎什么也没做?!
我不知道如何在Windows上完成它,但我知道如何在*nix上执行此操作.
我会编写一个sed/bash脚本(称为myscript),当使用git"smudge"过滤器通过git检出文件时,它会从文件中删除这些行.
所以在"$ GIT_DIR/info/attributes"中我会添加:
{sln filename} filter=myfilter
Run Code Online (Sandbox Code Playgroud)
并在"$ GIT_DIR/config"文件中定义过滤器的涂抹部分:
[filter "myfilter"]
smudge={path to myscript}
Run Code Online (Sandbox Code Playgroud)
对于Linux,我甚至可以像这样直接调用sed:
[filter "myfilter"]
smudge=sed '/GlobalSection(SubversionScc)/,/EndGlobalSection/ d'
Run Code Online (Sandbox Code Playgroud)
这可能是你可以使用git bash在windows中接管的东西.
当您想要检查文件的更改时要小心,因为它会检查"污迹"版本.您可以为此定义"干净"过滤器,以再次添加svn语句.