'In Visual Studio 2019, how to GIT commit only specific files (only .vb or .sln or .vbxproj files)?

Today, I want to Commit my work to my local GIT repository from Visual Studio 2019.

From Solution Explorer, I active GIT context menu and Commit action and a new Modification Git panel is displayed in which ALL modified and added files are displayed.

enter image description here

I can see a lot of files with a lot of types

.vb
.sln
.dll
.db
.dia
.cache
.pdb
.png

But I'm only interesting to commit .vb, .sln and .vbxprog file's types.

In Visual Studio, how can'I limit my commit to only these files ?

How can I do same thing for directory so that Release or Debug folders are never commited ?

Can I do all theses actions in Visual Studio level ?



Solution 1:[1]

You could:

  • either filter the list (*.vb in the filter field), to add only those files;
  • or switch to command-line and git add *.vb.

How can I do same thing for directory so that Release or Debug folders are never commited?

In command-line:

cd /path/to/local/repo
git rm --cached -r Debug/
git rm --cached -r Release/
echo Debug/>>.gitignore
echo Release/>>.gitignore
git add .gitignore
git commit -m "Ignore Debug and Release folders"

You don't need the git rm steps if no files in Debug/ or Release/ were ever tracked before.
But you need to add them to a .gitignore file.

Then you can switch back to Visual Studio: those two folders won't show up anymore.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC