38

I have been using the Git integration from within the Team Explorer section in Visual Studio 2015.

I have an number of config files in my solution that require modifications in order for the application to run locally but I don't want to commit those changes.

In VS2015 Update 1 there was an 'exclude' option in the 'Changes' section of the Git integration that I could select the modified config files and exclude them from the set of changes. Those files would then not appear in the list of modified files going forward so they stayed excluded for future commits.

Yesterday I installed Update 2 and now that exclude option has gone. I can't even see an 'ignore' so now I have to manually select the modified files and stage them each time which is now an extra step and has potential for me committing the local config changes by accident. I realise that having a staging area for the files about to be committed is the norm but the default for VS is to just commit everything. If I want to exclude the config files then I need to stage the other files and then commit.

Is there a way of getting back the previous functionality with the exclude option or failing that of ignoring the config files within the VS Git integration. I don't really want to add the config files to the Git ignore list because sometimes I do change those files legitimately and want to commit them.

Chris B
  • 5,311
  • 11
  • 45
  • 57

1 Answers1

45

Visual Studio now follows the Git terminology instead of the TFS source control Include/Exclude. In Git your changes are un-staged by default. From now on that's the case in VS too, and you can right click on the files you want to gather for the next commit and select "Stage". Once you staged some files, you can commit these staged files exclusively by Commit Staged button (the caption changes from Commit All after you stage at least one file).

As a shortcut however, when you want to commit every changed files at once - and all of them are unstaged initially - you can stage and commit them with one click with Commit All button.

First this surprised me. But knowing the Git terminology it totally make sense. Include/Exclude comes form the original TFS source control mechanisms, it served similar purpose, but it could have been confusing for those who where new to VS but knew Git.

Csaba Toth
  • 10,021
  • 5
  • 75
  • 121
  • 3
    I had not appreciated that the 'exclude' function was a TFS hangover. I guess the update does make sense in that it brings the expected Git behaviour to VS. Reading the [release notes](https://www.visualstudio.com/en-us/news/vs2015-update2-vs.aspx) there's some nice improvements to the history and quick links on the statusbar. So TL;DR you can't get the exclude option back but the new features are better ;-) – Chris B May 05 '16 at 10:27
  • 9
    Wow. This is really a step back in my opinion. I won't be able to convince anymore the other developers to switch to git. The workflow is just awful now. – JYL May 06 '16 at 15:05
  • I can get accustomed with the workflow, but often the merge conflicts can crash VS and it can get into a state where I have to use manual external tools to resolve conflicts. Pretty painful. – Csaba Toth May 31 '16 at 16:18
  • Using the git command line you can specify which files you want to commit. This is what was reflected by the include/exclude option. This is implemented by other git graphics clients by using check boxes to indicate which files you want to commit (like in TortoiseGit and Xamarin Studio). Staging is something different. – pauldendulk Aug 03 '16 at 12:41
  • 3
    I wish there was a way of disabling the "Commit All" and force the user to commit staged only. I've mistakenly committed files so many times already... – johnildergleidisson Feb 01 '17 at 19:47
  • @ Joao Milash: I agree, every time I accidentally commit my local environment_config.json file, the nightly build will put it on the development server thus breaking it. When that happens I will have to treat my development team members to Stroopwafels, It is getting costly. – Null Mar 21 '17 at 12:34
  • 1
    @Null `.gitignore` is your friend then: add `environment_config.json` to it. How many Stroopwafels will I get? – Csaba Toth Mar 21 '17 at 16:21
  • @Csaba unfortunately the environment_config.json file is already committed and tracked by git, adding it to .gitignore will accomplish nothing. Visual studio will keep trying to commit the file. So you will have to treat us to stroopwafels for accidentally checking in the file. :) – Null Mar 31 '17 at 13:48
  • @Null I'll tell a secret: when stuff looks weird always check the situation out with another Git GUI tool, or also just git command line. Turst me about this one, it works not only VS Studio, but other IDEs like InetlliJ as well. My favorite IDE external GUI is `tig`, which is also character based, so works in a terminal. But standard Git GUI is good as well. Sometimes things can get stuck in some weird state and with another tool you can get a second opinion on the situation. – Csaba Toth Nov 20 '18 at 02:50