在VisualStudio中有选择地接受git中的编辑?

在VisualStudio中有选择地接受git中的编辑?,git,visual-studio-2015,Git,Visual Studio 2015,我正在本地使用git进行我正在进行的MVC5项目。用户界面人员未使用任何源代码管理或visual studio。它的工作方式是——我将视图上传到FTP,他在那里进行更改。然后,我将在本地系统中下载(该系统将覆盖自上次上传到FTP以来所做的任何更改)并合并更改。所以基本上,由于我在并行处理相同的文件,他最终处理相同文件的旧版本 但谢天谢地,在几乎所有情况下,UI更改都与我自己的更改没有冲突,也就是说,它们与我的更改位于文件的不同部分。因此,我希望能够以某种方式有选择地提交更改。例如,VisualS

我正在本地使用git进行我正在进行的MVC5项目。用户界面人员未使用任何源代码管理或visual studio。它的工作方式是——我将视图上传到FTP,他在那里进行更改。然后,我将在本地系统中下载(该系统将覆盖自上次上传到FTP以来所做的任何更改)并合并更改。所以基本上,由于我在并行处理相同的文件,他最终处理相同文件的旧版本

但谢天谢地,在几乎所有情况下,UI更改都与我自己的更改没有冲突,也就是说,它们与我的更改位于文件的不同部分。因此,我希望能够以某种方式有选择地提交更改。例如,VisualStudio在“与Umodified进行比较”中显示更改,是否可以检查每个突出显示的更改并接受/拒绝提交

或者(但不是最好),是否可以检查更改并将两个版本的所有更改合并/提交到主分支中

我没有使用git命令行的经验,所以如果可能的话,我真的希望在VisualStudio中实现这一点

下面是一个例子-

原文-

<div class="form-horizontal">
    <h4>Balance</h4>
    <hr />
    <div class="form-group">
        @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-2" })
        @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control" } })
    </div>
</div>

平衡

@LabelFor(model=>model.Id,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.Id,new{htmlAttributes=new{@class=“form control”})
更新后的我的版本-(我刚刚将model.Id更改为model.Name,并添加了一个foreach循环)


平衡

@LabelFor(model=>model.Name,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.Name,new{htmlAttributes=new{@class=“form control”}) @foreach(model.Items中的var项){@item.Name}
更改后的版本-(他刚刚在顶部div中添加了一个名为tableview的新类)


平衡

@LabelFor(model=>model.Id,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.Id,new{htmlAttributes=new{@class=“form control”})

如您所见,更改在文件的不同部分。

建议您至少尝试使用
git gui
,它将为您提供文件中当前更改的可视化ui界面,并且您可以从该ui中选择要包含在下一次提交中的特定块或行

我一直使用它与其他工具(如Matlab*)一起使用,这些工具并不立即了解VCS集成

我可以挑选出我的粗略的临时更改,并使它们看起来像一系列经过深思熟虑的小步骤!(坏行可以从VCS记录中删除)


(*)Matlab确实具有一些VCS感知功能,但不是这种粒度。

您的更改是否已提交到本地存储库?或者他们只是坐在你的工作文件夹里?最好的选择是:让他们使用git。下一个最好的选择:使用分支和合并策略,每次你推到FTP,这是一个合并到“FTP”分支。来自其他开发人员的任何更改都位于ftp分支之上(换句话说,通过在通过ftp获得的内容之上进行提交,使用git“伪造”它们)。
<div class="form-horizontal">
    <h4>Balance</h4>
    <hr />
    <div class="form-group">
        @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
        @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
        @foreach(var item in model.Items) {<span>@item.Name</span>}
    </div>
</div>
<div class="form-horizontal tableview">
    <h4>Balance</h4>
    <hr />
    <div class="form-group">
        @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-2" })
        @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control" } })
    </div>
</div>