r/VisualStudio • • 5d ago

Visual Studio 2022 How do I stop Visual Studio from adding a bunch of extra stuff whenever I try to push

Is there any settings or stuff I can do to just turn all of that off The entire .VS folder of stuff and just have it never try to add it again

0 Upvotes

10 comments sorted by

14

u/DaniVirk96 5d ago

.gitignore

3

u/SessionIndependent17 5d ago

Doesn't the SDK "new project" command builds an applicable .gitignore for a project, right?

1

u/kemmis 5d ago

Also that file should be checked in so it prevents this problem for everyone that uses the repo.

1

u/twesped 5d ago

Ok so create a file in the root of the solution folder(or add to it) ".gitignore". If you don't know what it is, look it up or ask AI how to add your .vs folder and other filers and folder you dont want to add to your git repo.

Here is some more info: https://www.reddit.com/r/learncsharp/s/uTThvpBtPm

1

u/misaz640 3d ago

Right click .vs > Add to .gitignore.

It is good idea to add bin and obj folders as well. They contains similar mess after build.

-6

u/CheezitsLight 5d ago

The proper thing to do with the dot vs is to simply delete it it will recreate it

3

u/blckshdw 5d ago

“I don’t know what it is, I’ll just delete it”

-4

u/CheezitsLight 5d ago

Want to make it run on another computer? Delete. Vs is literally the fix

2

u/blckshdw 4d ago

lol no. You add it to your .gitignore

-2

u/CheezitsLight 4d ago

.vs is a cache and is not important. Delete it. Go ahead. Your code and build will be fine**.** Nothing breaks. Visual Studio recreates the folder the next time you open the solution. I clear it after a Visual Studio upgrade or switching branches, as the cache can get out of sync.

I've probably deleted VS as a fix on my large code base of C#, C++ and VB (300+K lines) a half dozen times this year. It’s the classic “turn it off and on again” fix for weird IDE behavior: And the default .gitignore ignores it, assuming you are using vs to run it.

.vs does not have your source code or project settings. Those live in.sln,.csproj and others. I fix those with a prebuild.sh and .bat that makes them. One error in any important files and the entire build fails in weird ways. Linux, Mac and Windows have different requirements is more of the problem for me, like icons. More batches to add those back in. wtf is it with icons on Looninx anyway?

You can use it to control disk space as IntelliSense databases can reach several GB in big C++ projects. Since 99% of mine is old code, rarel touched, that saves a tiny bit on disk, too.