.gitignore与Visual Studio 2013不起作用 [英] .gitignore with Visual Studio 2013 not working

查看:433
本文介绍了.gitignore与Visual Studio 2013不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个.config文件,我提交给github,现在不再需要跟踪的更改,称为PrivateConnectionStrings.config和PrivateSettings.config。我误解了VS2013的Git插件是如何工作的,或者是某些工作不正常。



我的.gitIgnore文件有很多条目,这里是我特别指出的:

  ** / PrivateConnectionStrings.config 
** / PrivateSettings.config

如果我修改其中一个配置文件,它将在解决方案资源管理器中显示指示更改的红色检查。当我进入团队资源管理器时,这是我所看到的,您会注意到文件更改显示在包含的更改中,而上下文菜单没有忽略文件的选项。 - 另外我在VS2013的FILE菜单下没有Source Control选项。



我也尝试删除ms-persist.xml。 git文件夹,并试图指出我不希望通过.git命令行对这些文件进行更改。





我只是不理解Git如何与VS一起工作,或者一般情况下还是关闭的?感谢您的任何指导。

解决方案


我有两个.config文件,我承诺github,现在没有更希望跟踪更改


将它们添加到 .gitignore 他们已经被追踪。



您应该使用假设 - 不变标志


I have two .config files I commited to github and now no longer want the changes tracked, called PrivateConnectionStrings.config and PrivateSettings.config. I'm either misunderstanding how the Git Plugin for VS2013 works or something is not working correctly.

My .gitIgnore file has many entries, here's what I have for specfically them currently:

**/PrivateConnectionStrings.config
**/PrivateSettings.config

If I modify one of the config files it shows the red check indicating change in the Solution Explorer. When I go to Team Explorer this is what I see, you'll notice it the file change shows in the included changes, and the context menu does not have an option for Ignoring the file. - Addtionally I do not have a "Source Control" option under the "FILE" menu in VS2013.

I have also tried deleting the ms-persist.xml in the .git folder, and also tried indicating I don't wish to follow changes on these file via the .git command line.

Here is my plugin selection:

Am I just not understanding how Git works with VS or in general or is something off? Thanks for any guidance.

解决方案

I have two .config files I committed to github and now no longer want the changes tracked

Adding them to .gitignore will not work since they are already tracked.

You should use the assume-unchanged flag
https://git-scm.com/docs/git-update-index

--[no-]assume-unchanged

When this flag is specified, the object names recorded for the paths are not updated.
Instead, this option sets/unsets the "assume unchanged" bit for the paths.

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

这篇关于.gitignore与Visual Studio 2013不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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