我们使用GIT和Visual Studio 2013(旗舰版和专业版)。解决方案和项目的代码在GIT中,每当我们在Visual Studio中重命名文件时,GIT都将其视为
c:\temp\testCodeSnippets>git status
# On branch master
nothing to commit (working directory clean)
c:\temp\testCodeSnippets>git status
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: OldName.cs
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# NewName.cs
no changes added to commit (use "git add" and/or "git commit -a")
git mv
c:\temp\testCodeSnippets>git mv OldName.cs NewName.cs
c:\temp\testCodeSnippets>git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: OldName.cs -> NewName.cs
#
基本上,在VS中执行的重命名仍然需要一些手动工作。同样重要 当从IDE内部进行重构时,会发生很多这样的重命名,即,重命名了类/成员/ etc,并且更改了所有引用。如果名称空间或类名更改,文件将被重命名。
因此,是否有任何设置需要切换,是否要安装任何工具,是否需要安抚,以便将Visual Studio中的重命名也映射为重命名为GIT(就像git mv
使之平滑一样)?
核心git(命令行应用程序)仅通过检测重命名为暂存的文件和暂定要删除的文件之间的名称来识别重命名。
但是,Visual Studio不会暂存您在操作期间进行的更改。相反,它将在提交时暂存更改。造成这种情况的原因有很多,但主要的原因是,进行更改会将文件放置在对象数据库中,并且每次保存都将花费巨大。
您将需要使用git add
和手动暂存更改git rm
,通过将添加的更改与重命名的更改进行比较,您的重命名将一如既往地被报告。
(请注意,Visual Studio –因为它不会随时进行更改,因此会同时检查已暂存和未暂存的文件以进行重命名检测。因此,Visual Studio将在核心git之前报告重命名。但是,当状态更改时,它们应在状态中显示相同的结果您进行这些更改。)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句