Visual Studio TFS Git 没有看到任何变化 [英] Visual Studio TFS Git not seeing any changes

查看:36
本文介绍了Visual Studio TFS Git 没有看到任何变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Visual Studio 的 Git for TFS 一无所知.

我在 TFS 上的 Git 中克隆了一位同事的解决方案并开始添加代码.然后我意识到我需要自己的分支来进行我所做的更改,因此按照 我可以用

git add

或更具体地说

git add -u .

暂存准备提交的文件,但我不愿意这样做,因为 在 Git 存储库中开发您的应用程序(跟踪、提交) Visual Studio 文档说明:

<块引用>

问:Git 阶段在哪里?
A:如果你是一个有经验的 Git 用户,你可能已经注意到Visual Studio 处理更改的方式与命令提示符不同.您可能想知道包含的更改部分是否包含你的阶段性变化.事实上,Visual Studio 通常会绕过 Git舞台给你.当您提交更改时,Visual Studio 同时阶段并提交它们.当您添加一个文件到您的 Git 存储库;Visual Studio 确实上演了这种改变.

Visual Studio 同时阶段和提交更改.但是为什么它没有列出我对跟踪文件所做的任何修改作为更改,从而让我提交它们?

解决方案

这与其说是一种解释,不如说是一种解决方法,但我发现如果我忽略了 文档当您提交更改时,Visual Studio 同时进行暂存和提交",而是使用命令将修改添加到暂存

git add -u .

然后 Visual Studio 突然意识到这些修改,让我在本地提交它们并将它们与 TFS 服务器同步.此外,它然后在我添加的文件上放置了新文件"绿叉,我发现我可以进行另一次提交,然后进行另一次同步以获取我所做的添加和删除.

从那时起,Visual Studio 就按照我的预期执行了操作:当我对文件进行更改时,该文件在提交窗口中列为已更改.

我仍然不知道为什么 Visual Studio 在最初的 git add 之后才发现更改,但至少现在它可以工作了.

I'm not getting something about Visual Studio's Git for TFS.

I cloned a colleague's solution in Git on TFS and started adding code. I then realised that I needed my own branch for the changes I was making, and so following the instructions in Push a new local branch to a remote Git repo and track it too I ran

git checkout -b e4ctim
git push -u origin e4ctim

When I make changes to my code visual studio shows the familiar red-tick icon by the code file to reassure me that the change has triggered the file to be checked out:

And then when I save the file the Visual Studio returns the icon to the blue padlock. I assume that this change from red-tick to blue padlock signifies that the change has been checked-in locally in Git:

But when I look at the history of the modified file, there is none!

I would like to commit my changes locally and sync them with the TFS server.

Visual Studio does not see any changes at all:

From the command line I can see that Git has noticed all of my modifications by running the command

git status

and seeing lots of changes not staged for commit and untracked files.

Looing at the Git book I could use

git add

or more specifically

git add -u .

to stage the files ready for a commit but I'm reluctant to do that as the Develop your app in a Git repository (track, commit) Visual Studio documentation states:

Q: Where is the Git stage?
A: If you are an experienced Git user, you might have noticed that Visual Studio handles changes differently than the command prompt. You might have wondered if the Included Changes section contains your staged changes. In fact, Visual Studio usually bypasses the Git stage for you. When you commit changes, Visual Studio simultaneously stages and commits them. The one exception occurs when you add a file to your Git repository; Visual Studio does stage this kind of change.

Visual Studio stages and commits changes simultaneously. But why is it not listing any of the modifications I have made to tracked files as changes, and thus letting me commit them?

解决方案

This is more of a workaround than an explanation, but I found that if I ignored the documentation "when you commit changes, Visual Studio simultaneously stages and commits them" and instead added the modifications to staging with the command

git add -u .

then Visual Studio suddenly became aware of the modifications and let me commit them locally and sync them with the TFS server. Moreover it then put the 'new file' green cross on the files I had added and I found I could do another commit and then another sync to pick up the additions and deletions I had made.

Since then Visual Studio is doing what I would expect: when I make a change to the file the file is listed as changed in the commit window.

I still do not know why Visual Studio failed to pick up the changes until after an initial git add but at least it works now.

这篇关于Visual Studio TFS Git 没有看到任何变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆