Visual Studio 2013 团队资源管理器/Git 集成缺少文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20937003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2013 Team Explorer/Git integration missing files
提问by Alex
I've set up Visual Studio 2013 with the native Git integration & BitBucket.
我已经使用本机 Git 集成和 BitBucket 设置了 Visual Studio 2013。
This has worked fine so far, but I noticed that Visual Studio stopped tracking newly created files (created through the IDE, such as simple new .cs files) for upload to BitBucket.
到目前为止,这运行良好,但我注意到 Visual Studio 停止跟踪新创建的文件(通过 IDE 创建,例如简单的新 .cs 文件)以上传到 BitBucket。
- Commit/Push for changes from already tracked files still works fine
- The new files are notshowing up in the Excluded Changes or Untracked Files lists
- The new files areincluded in the project files (and those are showing the correct changes)
- The files are definitely notexcluded any other way (.gitignore or otherwise).
- 从已经跟踪的文件提交/推送更改仍然可以正常工作
- 新文件未显示在“排除的更改”或“未跟踪的文件”列表中
- 新文件将被包含在项目文件(这些都出现在正确的变化)
- 绝对不会以任何其他方式排除这些文件(.gitignore 或其他方式)。
What else may cause the new files to not get tracked anymore?
还有什么可能导致新文件不再被跟踪?
回答by hawkke
I experienced something similar recently but excluding and then re-including the missing files didn't work for me. In VS2013 Premium, I noticed there's a "Untracked Files" section at the bottom of the Changes window. It was simply a matter of right-clicking the files I wanted to include and adding them. Not ideal, indeed, but another work-around.
我最近经历了类似的事情,但排除然后重新包含丢失的文件对我不起作用。在 VS2013 Premium 中,我注意到 Changes 窗口底部有一个“Untracked Files”部分。只需右键单击我想要包含的文件并添加它们。确实不理想,而是另一种解决方法。
回答by user3533716
I have the same problem as OP:
我和 OP 有同样的问题:
- Commit/Push for changes from already tracked files still works fine
- The new files are not showing up in the Excluded Changes or Untracked Files lists
- The new files are included in the project files (and those are showing the correct changes)
- The files are definitely not excluded any other way (.gitignore or otherwise).
- 从已经跟踪的文件提交/推送更改仍然可以正常工作
- 新文件未显示在“排除的更改”或“未跟踪的文件”列表中
- 新文件包含在项目文件中(并且这些文件显示了正确的更改)
- 绝对不会以任何其他方式排除这些文件(.gitignore 或其他方式)。
So, it appears that visual studio somehow thinks these files are tracked, while they're not, as they do not show up under untracked files.
因此,visual studio 似乎以某种方式认为这些文件已被跟踪,而实际上并没有,因为它们不会出现在未跟踪的文件下。
My workaround
我的解决方法
As I cannot add the untracked files in visual studio, the workaround is to use git bash, and manually do git add for each file that should be added. After that they work fine within visual studio again.
由于我无法在 Visual Studio 中添加未跟踪的文件,解决方法是使用 git bash,并为每个应该添加的文件手动执行 git add。之后,他们再次在视觉工作室中正常工作。
I hope this is fixed soon... apart from this bug, the git integration seems very nice from the short time I've tried it.
我希望这能尽快修复......除了这个错误之外,从我尝试过的短时间内来看,git 集成似乎非常好。
回答by xelandreb
even if it's quite old question, I've got a similar problem last week on VS2013 and none of previews workarounds are efficents for me. While editing a file, it's appear on Team Explorer list of modify files but, as soon as they are saved, they disaperead from any lists. Other tools (git bash, tortoise, ...) saw them as modify and uncommit but not VS. I solutionne this problem in the parameter of Git in Team Explorer by generating the .gitIgnore file of the solution ! I hope this could help.
即使这是一个很老的问题,上周我在 VS2013 上也遇到了类似的问题,并且没有任何预览解决方法对我来说是有效的。在编辑文件时,它会出现在团队资源管理器的修改文件列表中,但是一旦它们被保存,它们就会从任何列表中消失。其他工具(git bash、tortoise 等)将它们视为修改和取消提交,但不是 VS。我通过生成解决方案的 .gitIgnore 文件在 Team Explorer 的 Git 参数中解决了这个问题!我希望这会有所帮助。
It could be related to: Git changes not showing in VS2013 Update 2
回答by Steven Evers
I had the same problem where I added a .cs file, and VS doesn't recognize it as added, and won't included it in my changes.
我在添加 .cs 文件时遇到了同样的问题,VS 无法将其识别为已添加,并且不会将其包含在我的更改中。
As a workaround, you can open up SourceTree(mad by Atlassian to work with BitBucket), look at the "Unstaged Files" section, and right click > Add the file. VS will immediately pick up the change/add and you can commit via VS.
作为一种解决方法,您可以打开SourceTree(Atlassian 疯狂使用 BitBucket),查看“Unstaged Files”部分,然后右键单击 > 添加文件。VS 将立即接受更改/添加,您可以通过 VS 提交。
Not ideal, as you still can't trust/rely on VS to track your commits.
不理想,因为您仍然不能信任/依赖 VS 来跟踪您的提交。
回答by Dave Lampert
I experienced the same thing in Visual Studio 2013 version 12.0.21005.1 REL, where I would put a test file, hello.cs, in a particular folder and it would show up as "Untracked", and yet if I put the same file in a different folder, also in the same overall repository folder, it wouldn't show up anywhere (included, excluded, or untracked).
我在 Visual Studio 2013 版本 12.0.21005.1 REL 中遇到了同样的事情,我将测试文件 hello.cs 放在特定文件夹中,它会显示为“未跟踪”,但是如果我将相同的文件放入一个不同的文件夹,也在同一个整个存储库文件夹中,它不会出现在任何地方(包括、排除或未跟踪)。
It turns out that I had some deep folders with Bootstrap and JQuery that, themselves, had .gitignore and .gitattribute files, and when I simply renamed them to disabled.gitignore and disabled.gitattribute, and then hit the little refresh icon at the top of the Visual Studio Team Explorer pane, all my missing files sprang up again! Yeah!
事实证明,我有一些带有 Bootstrap 和 JQuery 的深层文件夹,它们本身就有 .gitignore 和 .gitattribute 文件,当我简单地将它们重命名为 disabled.gitignore 和 disabled.gitattribute 时,然后点击顶部的小刷新图标在 Visual Studio 团队资源管理器窗格中,我所有丢失的文件再次出现!是的!
It seems like it's a bug in Visual Studio 2013, and perhaps older versions, because I would have expected the .gitignore files to only have scope within their own folders, but they seem to carry on effect as Visual Studio continues traversing the entire folder hierarchy, and not particularly in alphabetical or depth-first/depth-last sequence!
这似乎是 Visual Studio 2013 中的一个错误,也许是旧版本,因为我原以为 .gitignore 文件只在它们自己的文件夹内有范围,但随着 Visual Studio 继续遍历整个文件夹层次结构,它们似乎继续生效,而不是特别是按字母顺序或深度优先/深度最后的顺序!
回答by Jozef Cechovsky
I have similar issue and my solution is using of the TortoiseGit. If I want to commit, in section "Not versioned files" TortoiseGit shows me files not matched in .gitignore but added to file system . You can simply check all (if you'd like to add them) and press commit.
我有类似的问题,我的解决方案是使用 TortoiseGit。如果我想提交,在“Not versioned files”部分 TortoiseGit 会向我显示 .gitignore 中不匹配但已添加到文件系统的文件。您可以简单地检查所有(如果您想添加它们)并按提交。
This is not only one issue with Visual Studio Git. Especially general error messages with no value. Every time I had to switch to the TortoiseGit or to the Git bash to find what Visual Studio Git tool doesn't like.
这不仅仅是 Visual Studio Git 的一个问题。特别是没有价值的一般错误消息。每次我不得不切换到 TortoiseGit 或 Git bash 以找到 Visual Studio Git 工具不喜欢的地方。
回答by How 'bout a Fresca
I resolved this by adding a .gitignore
file in my local repository at the same level as my .git
folder.
我通过.gitignore
在与.git
文件夹相同级别的本地存储库中添加一个文件来解决此问题。
- In Team Explorer while connected to your Git project, click the drop-down and select
Settings
- Under
Git
clickGit Settings
- Toward the bottom, under
Repository Settings > Ignore File
clickAdd
- 在连接到 Git 项目的团队资源管理器中,单击下拉菜单并选择
Settings
- 在
Git
点击下Git Settings
- 朝底部,在
Repository Settings > Ignore File
点击下Add
This will create a default .gitignore file for you. This worked for me, but you can also replace then content of the file with the something like what is recommended here: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
这将为您创建一个默认的 .gitignore 文件。这对我有用,但您也可以用这里推荐的内容替换文件的内容:https: //github.com/github/gitignore/blob/master/VisualStudio.gitignore
Hope this helps somebody!
希望这对某人有帮助!
回答by Jan Van der Haegen
Old post, but encountered a new cause to this problem. I got it after including a downloaded plugin. The plugin had it's own .git folder in it, which seemed to interfere with VS's git. After removing the folder, I renamed every non-tracked file then named it back to the original, and VS started adding the + in front of the files indicating they are now tracked...
旧帖子,但遇到了这个问题的新原因。我在包含下载的插件后得到了它。该插件中有它自己的 .git 文件夹,这似乎干扰了 VS 的 git。删除文件夹后,我重命名了每个未跟踪的文件,然后将其命名回原始文件,并且 VS 开始在文件前添加 + 表示它们现在已被跟踪...
回答by David Wolfe
I had this issue. Removing from the project and adding it back didn't work, even when doing commits between each step. I ended having to use Source Tree to write the commit, and the use VS to push it to vsto.
我有这个问题。从项目中删除并重新添加它不起作用,即使在每个步骤之间进行提交也是如此。我最终不得不使用 Source Tree 来编写提交,并使用 VS 将其推送到 vsto。
回答by Constant
I've experienced the same issue and non of the mentioned solutions helped. I wasn't able to commit a file in any way to Bitbucket Git repo from VS2015. What I've ended up with is I've made a change to the file (didn't save it), staged the file and then commit it. Source Tree also was able to track it as 'Added'.
我遇到了同样的问题,并且没有提到的解决方案有帮助。我无法以任何方式从 VS2015 向 Bitbucket Git 存储库提交文件。我最终得到的是我对文件进行了更改(没有保存它),暂存文件然后提交它。Source Tree 还能够将其跟踪为“已添加”。