Are there any general patterns that in a git repository you always need to add to .gitignore and that you definitely shouldn't?
Inspired by this question: What should be in gitignore for Visual Studio?
Are there any general patterns that in a git repository you always need to add to .gitignore and that you definitely shouldn't?
Inspired by this question: What should be in gitignore for Visual Studio?
target/ , output/ , release/ , debug/ . These files can be obtained from the source code, so their versioning does not make sense.*.log ), work results, etc.*~ .thumbs.db , .DS_Store.git folder itself (in any case, it cannot be added to the index) and other files: .gitattributes , .gitignore .Required OS system files and backups
### Linux template *~ # KDE directory preferences .directory # MacOS .DS_Store .AppleDouble .LSOverride IDE files themselves (if you are working on LAN)
### NetBeans template nbproject/private/ build/ nbbuild/ dist/ nbdist/ nbactions.xml nb-configuration.xml .nb-gradle/ ### JetBrains template # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio *.iml ## Directory-based project format: .idea/ Different plugins
## Plugin-specific files: # IntelliJ /out/ # mpeltonen/sbt-idea plugin .idea_modules/ # JIRA plugin atlassian-ide-plugin.xml # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties crashlytics-build.properties File system
# Thumbnails ._* # Files that might appear in the root of a volume .DocumentRevisions-V100 .fseventsd .Spotlight-V100 .TemporaryItems .Trashes .VolumeIcon.icns # Directories potentially created on remote AFP share .AppleDB .AppleDesktop Network Trash Folder Temporary Items .apdisk Addition
From @Timofey Bondarev comment
It turns out there is a convenient site for generating .gitignore - https://www.gitignore.io
# Created by .ignore support plugin (hsz.mobi) - korytoffAnd now I’ve got in and give an unpopular opinion.
Do not dare copy-paste "standard" .gitignore. You must understand each line, otherwise you will sink into the stream of WTF.
All this should be in the global .gitignore, and not copy-paste to each repository. If your operating system is crap in the file system, then deal with it at the system level, and not every repository you work with.
IDE files and everything connected to it. You need to understand what files are and what for. For the sake of example:
R # + C #: MySolution.sln.DotSettings - the "command" settings for the project, MySolution.sln.DotSettings.user - the "personal" settings for the project (there are still "system", they are in another place). It is necessary not only to make sure that the correct file is signed, but also that the changed settings fall into the necessary file, otherwise there will be disagreements with the command.
IDEA: there are acidic manuals on what files to store and why. You can't just ignore .idea/ , because the project settings will fall off. You can’t just leave and leave .idea/ , because your personal ways will get to everyone and give birth to conflicts. In other environments, files can be from zero to infinity, get ready to explore your tool.
Generated during assembly files. There are different traditions in different languages and environments, and serious disputes flare up around individual files. For the sake of example:
Composer + PHP: Keep or not store composer.lock - depends on the priorities of the command, library or application you are developing, and on personal tastes. You need to be well aware of the pros and cons of finding a file in the repository.
T4 + C #: It is common in C # to store code generation output so that you can easily build a project. In this case, you can customize the assembly so that code generation starts when you build it, but this is not possible for all scripts. It should be noted that non-T4 code generation usually falls into Output, and therefore is ignored. In other languages and environments more often they profess an ideology that the output of code generation will never commit.
Binary Git disgustingly works with binaries, unlike backward VCS like SVN. The repository grows prohibitively if files are updated frequently.
If you rarely update files and they are small, you can put the files in place.
Otherwise, it is better to hide files in some other place. There are both universal crutches for Git (Git LFS), and language and environment-specific tools (personal NuGet server).
If you can use NuGet, Composer, CPAN, Lein, Maven, then use. Binary dependencies should be there.
You should strive to ensure that the repository has the minimum possible number of files, which are enough to build the entire project with absolutely no interference and configuration of anything.
Often the ideal is unattainable. So look for a compromise.
[core] excludesfile in .gitconfig . At user level. - AthariSource: https://ru.stackoverflow.com/questions/474556/
All Articles