A comprehensive git ignore file [closed] - gitignore

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 months ago.
Improve this question
Over the years, I have worked in developing programs in C# and Unity and Python and Django and applications for HoloLens and Oculus with IDEs like Visual Studio and Visual Studio Code and also web dev in Angular and TypeScript and JavaScript.
I have gathered everything that I believe should be ignored for any project that involves development in these languages and frameworks, but all in one git ignore without causing issues for each other.
So far, I have the following. I do wonder though if someone might spot something that should not be in here or perhaps redundant:
[Dd]ebug/
[Dd]ebugPublic/
[Bb]uild/
[Bb]uilds/
[Pp]ackage/
[Pp]ackages/
[Rr]elease/
[Rr]eleases/
[Ll]ogs/
[Ll]og/
[Uu]wp/
[Aa]pp/
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]in/
[Bb]ackup*/
[Ee]xported[Oo]bj/
3rdParty/
[Tt]hirdParty/
[Aa]ssets/3rdParty/
[Aa]ssets/[Tt]hirdParty/
[Aa]ssets/[Tt]hirdParty.meta
[Aa]ssets/[Pp]lugins*
[Aa]ssets/[Aa]sset[Ss]tore[Tt]ools*
/.vs/
.vscode/
*.bak
._*
~$*
*~
obj/
x64/
x86/
Installer/
App/[pP]layers/
WindowsStoreApp/
HoloSymMDL2*
Assembly-CSharp.csproj
WSATestCertificate.pfx
WSATestCertificate.pfx.meta
UnityVS*
UnityGenerated/
UnityPackageManager/
project.json
project.lock.json
project.fragment.lock.json
/*.csproj
*.csproj
*.booproj
*.unityproj
*.unitypackage
*.log
*.user
*.userprefs
*.userosscache
*.sln.docstates
*.sln
/*.sln
*.suo
*.svd
*.swp
*.tmp
*.tmp_proj
*.opendb
*.pdb
*.pidb
*.pdb.meta
*.pidb.meta
*.apk
*.blend[1-9]
StyleCop*
*.stackdump
sysinfo.txt
.Trash
.Trashes
.DS_Store
.DS_Store?
.Spotlight-V100
$RECYCLE.BIN/
.consulo/
*.coverage
*.coveragexml
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
.JustCode
_TeamCity*
*.dotCover
_NCrunch_*
.*crunch*.local.xml
*.mm.*
AutoTest.Net/
.sass-cache/
[Ee]xpress/
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*.VisualState.xml
TestResult.xml
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
_Chutzpah*
*.ide/
*.psess
*.vsp
*.vspx
$tf/
*.gpState
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
publish/
*.[Pp]ublish.xml
*.azurePubxml
*.pubxml
*.publishproj
*.nupkg
**/packages/*
!**/packages/build/
csx/
*.build.csdef
AppPackages/
*.cert
*.privkey
*.pfx
*.pfx.meta
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
*.dbmdl
*.dbproj.schemaview
*.publishsettings
node_modules/
Generated_Code/
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
*.mdf
*.ldf
*.rdl.data
*.bim.layout
*.bim_*.settings
FakesAssemblies/
[Ee]hthumbs.db
[Ee]hthumbs.db.meta
[Tt]humbs.db
[Tt]humbs.db.meta
Desktop.ini
*.cab
*.msi
*.msm
*.msp
/node_modules
/.pnp
.pnp.js
/coverage
/build
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*
Bin/
Assets/AssetStoreTools*
App/
UWP/
.vs/
ExportedObj/
*.lnk
*.ipch
*.obj
*.tlog
*.idb
Thumbs.db
ehthumbs.db

I do not think it is an interesting idea. Because we may inadvertently ignore some files.
I prefer to add the file to ‍.gitignore as soon as I feel the need.
This site also offers an interesting option, for example, you select a framework and you can use the output in your projects.
Also, the IDEs themselves have plugins or extensions that can create a .gitignore file for you depending on the project.
For example this plugin from IntelliJ or this extension of VS Code
Feeling your need is valuable.

Having a one for all .gitignore is a terrible idea. Every project should be in it's own folder. So use a specific .gitignore for each project folder. E.g. use the Unity .gitignore for your Unity project, your Angular .gitignore for your Angular project and so on.

Related

Unity Gitignore not ignoring binary files

I have a problem with the .gitignore file in my Multiplayer Unity game project (consists of a game server and a client project in a single repository). The .gitignore file ignores most of the files, but not the binary files from the library artifacts.
Image of binary files showing in Github Desktop.
I know the .gitignore file works because if I remove it there is 30000 changed files and 8000 without removing it.
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
[Uu]ser[Ss]ettings/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.aab
*.unitypackage
# Crashlytics generated file
crashlytics-build.properties
# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
Image of the repository folder with the 2 projects
hehe i think your answer is on the first line of the .gitignore
This .gitignore file should be placed at the root of your Unity project directory
All of those ignore paths without a preceeding / are only relative to the location of the .gitignore. It works like so:
Will ignore:
./Build/myBinary
Will not ignore:
./project1/Build/myBinary
./project2/Build/myBinary
Simplest solution is to duplicate your .gitignore and place one of each at the root of each project directory, not the repo directory.
Your directory should look like this:
myRepo
project1
.gitignore
Assets
...
project2
.gitignore
Assets
...
As mentioned, if files in these directories have already been committed they will need to be removed manually.
To be sure, assuming there are only binaries in this folders, try and delete them (from the Git index only, not from your disk), and check immediately (no commit needed) if your .gitignore applies.
cd /path/to/repo
git rm -r --cached path/to/folder/with/binaries/ # note the trailing slash
git check-ignore -v path/to/folder/with/binaries/aBinary # must be a file
If the last command does not return anything, then no .gitignore rule applies.

What source code files should be included in version control for Ionic2 application?

Im building an Ionic 2 application. Version control will be made through SVN.
When creating the app using ionic CLI many files are generated. Same happens when adding platforms.
Is there any standard approach defining which files to include in Version Controls and which ones to ingnore. (I.E. i think platforms folder should be ignored).
You can always take a look at the conference app to see how Ionic team recommends to do things. In this case the .gitignore file looks like this:
# Specifies intentionally untracked files to ignore when using Git
# http://git-scm.com/docs/gitignore
*~
*.sw[mnpcod]
*.log
*.tmp
*.tmp.*
log.txt
*.sublime-project
*.sublime-workspace
.vscode/
npm-debug.log*
.idea/
.sass-cache/
.tmp/
.versions/
coverage/
dist/
node_modules/
tmp/
temp/
hooks/
platforms/
plugins/
plugins/android.json
plugins/ios.json
$RECYCLE.BIN/
.DS_Store
Thumbs.db
UserInterfaceState.xcuserstate
Like you can see there, the platform and the plugins folders are being ignored for example
Common Ignores
.vscode/
.DS_Store
ionic
node_modules/
plugins/
Platform iOS
*.mode1v3
*.perspectivev3
*.pbxuser
platforms/ios/build
Platform Android
platforms/android/build.xml
platforms/android/local.properties
platforms/android/gradlew
platforms/android/gradlew.bat
platforms/android/gradle
Ant builds
platforms/android/ant-build
platforms/android/ant-gen
Eclipse builds
platforms/android/gen
platforms/android/out
Gradle builds
platforms/android/build
Check - https://github.com/ionic-team/ionic/blob/master/.gitignore

What does your .gitignore file look like for a Unity project?

I'm starting out with Unity and I've noticed that even with small code changes result in a large git diff.
Originally, my .gitignore just had this:
Temp/
but it's not doing much heavy lifting.
I found this .gitignore template on Github, but I'm curious if anyone else uses this--either as a starting point or as-is.
I use to use that same .gitignore with no issues at all, as-is. Works on both macOS and Windows.
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*
# Visual Studio 2015 cache directory
/.vs/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
# Unity3D generated meta files
*.pidb.meta
# Unity3D Generated File On Crash Reports
sysinfo.txt
# Builds
*.apk

Why does TortoiseHg not add packages.config

I use NuGet for package management on my .NET projects and one thing that happens consistently is that the package.config files get ignored for commit unless I explicitly add them. With any other file that is not specifically filtered by my .hgignore TortoiseHg suggests it be included in the commit dialog.
The contents of my .hgignore is this:
# Ignore file for Visual Studio 2008
# use glob syntax
syntax: glob
# Ignore Visual Studio 2008 files
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
*.orig
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
build*/
_ReSharper*/
[Pp]ackages*/
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
Thumbs.db
desktop.ini
I see the None of this is tragic, just a bit of friction. Any thoughts as to why the package.config is being ignored?
Edit: OK I see the line that is likely responsible:
[Pp]ackages*/
I think then the question is what pattern do I need that will filter out my packages directories, but let packages.config through? My regex is not so good so any help is appreciated.
Delete [Pp]ackages*/ from glob section and add regexp-section with negative lookahead for package.config (TBT!):
syntax: regex
^packages.*/(?!package\.config$)

What is the 'standard' content of .gitignore for an iPhone (Xcode) project?

What is considered the 'standard' content of .gitignore file for an iPhone (Xcode) project?
PS: not sure if this needs to be a CW.
build/
.DS_Store
**/*.pbxuser
*.mode2v3
*.mode1v3
**/*.perspectivev*
This is a good start.
updated with Dave's suggestions.
You should also exclude xcworkspace and xcuserdata in xcode 4.2. So here is a complete list which one should ignore for iOS projects
# Exclude the build directory
build/*
# Exclude temp nibs and swap files
*~.nib
*.swp
# Exclude OS X folder attributes
.DS_Store
# Exclude user-specific XCode 3 and 4 files
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
xcuserdata
From the GitHub gitignore project, as of today:
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
Source: https://github.com/github/gitignore/blob/master/Objective-C.gitignore