If you are new and want to add source control to your Xamarin projects using Git, when you created a new repository and started to add your Xamarin projects, you may notice that there were a lot of files ready to commit which you didn’t want in version control.
So, in order to solve that we need to set up a .gitignore file. But better than that I am going to share with you my own .gitignore file for Xamarin projects.
How to create a .gitignore file
Built-in set up
Visual Studio 2019 has a builtin set up and now you add your source control in a new project easily. You just need to
- Click Add to Source Control in the bottom right bar of VS next to the notification icon.
- And select Git.
This automatically adds .gitatribbutes and .gitignore files with a builtin set up.
Make your own
gitignore.io is an open-source utility that can help you create useful .gitignore files for your projects. From here you can get the Visual Studio and Xamarin Studio .gitignore files as a base.
You could add the file manually, but then you would not get a nice set of default values. If you do decide to add the file manually this repo contains all the defaults that should be ignored for a project using .NET/Visual Studio.
Add .gitignore file to existing Visual Studio Project
Inside of Visual Studio opens the Team Explorer window. If you don’t already have it open use the quick launch in the upper right-hand side of the window to search for it. If it is not already on the Home page click the house icon at the top of the Team Explorer window.
- Click the settings option.
- Then click Repository Settings.
- Now click the add link next to the Ignore File description.
This will add the .gitignore file will all the defaults set for things that should be ignored.
My .gitignore file for Xamarin projects
In most cases, the file generated by Visual Studio is probably sufficient but having already done some research I thought that wasn’t fit Xamarin right now so I finish the job. To do that, I have taken the default Visual Studio generated .gitignore file and made my own.
And you can download here 👇👇👇👇
[bucket id=”11123″ title=”Thanks for reading”]