0

I just noticed the files I created (.cs, .xaml, etc) are not added to Git, so my commits+push wont upload them to the repository. I know I can go to the terminal and do git add path/to/file but I want to know how can I do this from within Visual Studio.

I tried right-click the file and search for Add to source control but the option is not listed. What do I do?

I already looked it up but every Microsoft documentation is for Team Foundation and it doesn't work for me

Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206
  • I assume you've read through http://www.bing.com/search?q=visual+studio+integration+vs+git and this result http://stackoverflow.com/questions/507343/using-git-with-visual-studio in particular already... So please clarify what else you are looking for. – Alexei Levenkov Jan 20 '15 at 22:30

1 Answers1

2

Make sure Microsoft Git Provider is selected as your Source Control plugin (assuming Visual Studio 2013):

  1. In Visual Studio, on the Tools menu, click Options.
  2. In the Options dialog box, click Source Control, then click Plug-in Selection.
  3. Select the source control plug-in that you want to use (Microsoft Git Provider).
  4. Click OK.

Locks should appear next to your files (assuming your project is a git repository), and you should be able to add your files.

Reference: https://msdn.microsoft.com/en-us/library/axafab5c(v=vs.90).aspx

Edit: Since you already have your plugin set correctly, you likely just need to perform a commit. I don't believe Visual Studio has a seperate interface for staging changes; when you go to commit, it should list your new files as "Included Changes", and the file should have a green plus next to it in the Solution Explorer.

Any files that aren't being committed should be listed under Excluded Changes or Untracked Files below that. You can add individual files to the commit from here.

If your file is missing the green plus, I'd check your .gitignore file to ensure it's not being ignored.

Community
  • 1
  • 1
Will Eddins
  • 13,628
  • 5
  • 51
  • 85
  • The issue is that on some files, the little blue locks are not present. And right-clicking on them doesn't show anything related to add them to source control – Christopher Francisco Jan 20 '15 at 22:34
  • @ChristopherFrancisco Check my edit, you probably just need to commit and it should list it as an included change. I just verified on my own project. – Will Eddins Jan 20 '15 at 22:37
  • "Included Changes", that solved it. Is there a way to automatically adding newly created files to git without having to go there manually? – Christopher Francisco Jan 20 '15 at 22:38
  • @ChristopherFrancisco If you're committing outside of Visual Studio, then no. If you are, files that I create in Visual Studio are automatically included for me, so I'm not sure what the difference there would be. – Will Eddins Jan 20 '15 at 22:39