I’m wondering which files I should add to git and which ones to ignore. I can (read 'should') add the entire project folder?
You can add as many files as you want. The problem itself is that there are files that are not part of the development. These files should be ignored.
In python projects, I ignore "pycache". There is something like this in C# since Visual Studio (Community 2017) creates several folders and files?
In this case, you should focus on all files that are not important for project development.
For example, it makes no sense to commit log files, temporary folders, compiled files, upload folders, or files belonging to the library you are using.
In the latter case cited, when you will manage libraries of your project, you must commit the file responsible for controlling the management of their versions, and not the library archives themselves. For example, in Python projects instead of commiting the folder venv
containing all dependencies, you must commit the requirements.txt
; in the case of PHP, instead of commiting the folder vendor
, you should only commit composer.json
and composer.lock
; In the case of VOLTARPM, you should not commit node_modules
, and yes package.json
. And so on and so forth.
The other developer who will develop together with you will, for example, run the npm install
(or any other language library manager used) to install the dependencies on its machine.
For the files of node_modules
are not part of the project, are only used by him as dependency.
In short
Do not focus on having a magic formula or just try to copy and paste from the internet the pattern to be followed for a .gitignore
of a project.
To strengthen the idea, here is a translation of the documentation itself GIT
:
Standards that must be controlled by version and distributed to other repositories via clone (i.e., files that all developers will want to ignore) must enter a file .gitignore
.
A clear example of what is described above is a file .env
(used in some languages to set local application settings). It makes no sense to add this to your repository, since it has your local database settings. If you send such a file in a commit, every time the developer who is working with you will have to edit and repair the database configuration.
This site gitignore. is an online tool that generates . gitignore files according to the specified language. It is a very useful tool. On the home page just write the name of the language and click create. For your case just write Csharp it generates the file . gitignore.
– Vinicius Fernandes