Exclude file in Visual Studio from default git commit

Several developers are working on the project, and each of them has its own connection string in Web.Config. From time to time (usually several hours!), The developer forgets to exclude web.config from his commit, and soon everyone should go through at least a cycle of receiving errors, having discovered that due to an incorrect connection string, and correct it. The reason is that when people prefer to commit their changes, VS adds all the changes to commit. They may exclude it, but they forget it.

Is there a way to exclude a file from default commits ? Note that this is different from excluding a file from the repository that can be done in .gitignore.

+4
source share
3 answers

Ok It turns out that a solution to the original problem is possible. A complete guide is in this post by Scott Hanselman. The main idea is that you can put part of the configuration data into another file, and then access this file from web.config. This file can be excluded from the source control in .gitignore, as usual.

<appSettings file="Web.SECRETS.config">      
    <add key="name" value="someValue" />
</appSettings>
+12
source

This cannot be done using Visual Studio.

You have 2 options ... Either use the best git gui that manages the staging area: Gitextensions or sourcetree.

, , , git ( ), , . ...

+1

There is an even better solution to your problem. You can easily create your own ASP.NET 5 configuration in any .NET application (older versions of ASP.NET, console applications, etc.):

http://dusted.codes/aspnet-5-like-configuration-in-regular-dotnet-applications

0
source

Source: https://habr.com/ru/post/1611272/


All Articles