Tuesday, July 26, 2016

Staged and unstaged files in Git using Visual Studio

Most developers have a common scenario of managing Web.config files among teams due to differing database connection strings.  If everyone is using a local instance of SQL Server or SQL Server Express, this might be able to be managed readily but if the connection strings are pointing to a shared server, this database connection string might change across development teams.  This issue is particularly prominent in offshore development teams whereby onshore and offshore development teams might need to use different database connection strings.

If you are using a source control repository such as Git, though, managing these individual changes among developers is a relatively easy task by leveraging Staged and Unstaged files!

Once you have a list of changes in Visual Studio Team Explorer, you can right click on one or more files to choose to Stage these files:

Once you have selected the files to Stage, you will end up with a list of Staged Changes and Changes (Unstaged Changes):

The files that are listed as Unstaged Changes will be excluded from being pushed to Git as follows by using the "Commit Staged" set of commands:

This allows isolated changes (such as those made to the Web.config file) to remain locally on developer machines while changes to other files can continue to be pushed to Git!

1 comment:

  1. Bluehost is definitely the best web-hosting provider for any hosting plans you require.