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.
Related
This is my .gitignore (.gradle/ in the 17th line):
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/gradle.xml
# .idea/assetWizardSettings.xml
# .idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
*.jks
*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
# MacOS
.DS_Store
# App Specific cases
app/release/output.json
.idea/codeStyles/
# Android Profiling
*.hprof
Yet, when I view the list of unstaged changes, I see there some files under the .gradle/ folder:
Why aren't these files ignored like other .gradle files?
If they were already committed before adding the .gitignore you'll need to untrack them. Does Ignore files that have already been committed to a Git repository help?
I am trying to make git ignore the opencv2.framework I have imported into my project. However, even though I am adding opencv2.framework into my .gitignore, every time I run git status on my terminal, all the opencv2.framework files are showing up as new files. Could anybody help? Thanks! This is what my .gitignore file looks like: (I wrote opencv2.framework under ##Various Settings)
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
opencv2.framework/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
.build/
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
Just in case, see if git status changes after:
cd /path/to/my/repo
git rm -r --cached opencv2.framework/
If it does (and you don't see anymore opencv2.framework/ files), commit your current state.
You need to execute the git rm -r --cached:
in the parent repo of the folder to remove (parent of opencv2.framework/).
Do add and commit (and eventually push), in order to record that deletion from the git repo (but not from the disk, thanks to the --cached option);
in order to delete those tracked files, as a .gitignore rule only applies to untracked files.
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
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
In our semester group we are using eclipse as an IDE for developing a Compiler. The issue is when it comes to git. Which files are okay to be ignored and which are crucial. It works fine on my computer, but when it is synced with git and another member from the group is trying to use the workspace, there always seem to be some errors about main not showing or a package is wrong.
Bottom line: What is okay, and what is not okay to include in .gitignore file, so that every group member is able to compile the project?
I think the best solution is to generate .gitignore for yourself by gitignore.io.
Just choose tools that you used.
It depends on your requirement.
Usually Compiled source,Packages, Logs and databases, Eclipse specific files/directories are removed from git push. Also can keep configuration in separate(property) file.It is easy to place project in a different environment.
This is a sample gitignore file
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
# Editor Files #
################
*~
*.swp
# Gradle Files #
################
.gradle
.m2
# Build output directies #
##########################
/target
*/target
/build
*/build
# IntelliJ specific files/directories #
#######################################
out
.idea
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml
# Eclipse specific files/directories #
######################################
.classpath
.project
.settings
.metadata
# NetBeans specific files/directories #
#######################################
.nbattrs