Reputation: 884
Every where on the internet says "this is how you set up your .gitignore." "You want to have one so you can ignore files." "Blah Blah Blah." But my question is "Why?" Why do I need to not include certain files from the repo? I understand that you don't want to have files that have sensitive info in there, but what about generated files? What about some of the other types of files that we are said to ignore? I get that this is something we should do... but why?
Upvotes: 1
Views: 1518
Reputation: 3152
Best practice is to avoid any files that are generated by simply building your project. If your are working on big projects why should every branch for every developer contain files that are not necessary to build a project? This means that if you have merge conflict you mostly have them twice, you can't see what has changed properly etc.. You want to keep your commits as clean as can be, just to keep order and to avoid conflicts while pushing and pulling.
But this only make sense when working on projects in teams.
Upvotes: 0
Reputation: 601351
You want the repository to keep track of the work you did. Commits should reflect your manual changes, and looking at the patch history should let other people understand what was changed and why.
If you were to include all auto-generated files in the repository, your commits would get cluttered up with changes to auto-generated files, making it difficult to understand what the actual change was, thus reducing the overall utility of using a version control system.
Upvotes: 0
Reputation: 107237
Typically, you won't want derived and intermediate compile artifacts like .obj
, pre-compiled headers, 3rd party binaries which are versioned and easily downloadable, unit test output gunk, and sometimes also the compiled binaries themselves cluttering up your repository. Other common files to exclude are per-developer configuration and preference files, e.g. for IDE environment theme and shortcut preferences.
Provided you check in all of your actual sources, you can rebuild any version at any time, so nothing valuable is lost by not checking these in. It can also be argued that binaries aren't first class citizens in a version control system anwyay, given the inability for visual diffs to be done on these.
There are standard preconfigured .gitignore
setups for most common language / environment setups here
Upvotes: 6
Reputation: 1
Some files on your project are particular to your environment and commonly generated by your editor. And they are better off not tracked, as your repository will be smaller in size, have only files meaningful to your project and you will have to deal with less merge conflicts, as these files usually change from environment to environment.
Upvotes: 0