我们使用GIT和Visual Studio 2013(Ultimate + Professional版本).解决方案和项目的代码在GIT中,只要我们在Visual Studio中重命名文件,GIT就会将它们视为
c:\temp\testCodeSnippets>git status
# On branch master
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)
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")
Run Code Online (Sandbox Code Playgroud)
git mvc:\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
#
Run Code Online (Sandbox Code Playgroud)
基本上,在VS中执行的重命名仍然需要一些手动工作.同样重要; 从IDE内部重构时会发生很多这些重命名,即类/成员/等被重命名并且所有引用都会发生更改.如果命名空间或类名更改,则重命名文件.
那么,是否有任何设置要切换,任何安装工具,任何神仙安抚,以便从Visual Studio重命名也被映射为重命名为GIT(就像git mv让它顺利)?
核心git(命令行应用程序)仅通过在添加的文件和暂存的文件之间检测重命名来识别重命名.
但是,Visual Studio不会对您在操作期间所做的更改进行分阶段.相反,它将在提交时暂存更改.这有几个原因,但主要是暂存更改将文件放在对象数据库中,并为每次保存执行此操作将非常昂贵.
您需要使用git add和手动暂存更改,git rm并且通过将添加的更改与重命名的更改进行比较,将一如既往地报告您的重命名.
(请注意,Visual Studio - 因为它不会逐步调整您的更改 - 检查用于重命名检测的分阶段和非分段文件.因此Visual Studio将在核心git之前报告重命名.但是,它们应该在状态时显示相同的结果你发布这些变化.)
| 归档时间: |
|
| 查看次数: |
3219 次 |
| 最近记录: |