.gitignore with Visual Studio 2013 not working

落爺英雄遲暮 提交于 2020-01-07 03:04:32

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/34291782/gitignore-with-visual-studio-2013-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!