Last active
October 12, 2019 19:19
-
-
Save sunsided/506105bee18a92801c7665ca1a9fcfa0 to your computer and use it in GitHub Desktop.
Git for Unity repository bootstrapping including .gitignore, .gitattributes, and Git-LFS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eo pipefail | |
echo "Creating Git repository ..." | |
git init | |
echo "Applying private user configuration ..." | |
git config user.name "<YOUR NAME>" | |
git config user.email "<YOUR EMAIL ADDRESS>" | |
git config user.signingKey "<YOUR GPG SIGNING KEY>" | |
# Configuring Unity YAML merge | |
# - https://docs.unity3d.com/Manual/SmartMerge.html | |
# - https://gist.github.com/sunsided/506105bee18a92801c7665ca1a9fcfa0 (unity-merge script) | |
# - https://gist.github.com/sunsided/366d7b6e4e8c3df14fea9b9c3f628d6f | |
echo "Configuring YAML merge" | |
git config mergetool.unityyamlmerge.trustExitCode false | |
git config mergetool.unityyamlmerge.cmd 'unity-merge merge -p "$BASE" "REMOTE" "$LOCAL" "$MERGED"' | |
echo "Creating standard files ..." | |
if [ ! -f "README.md" ]; then | |
echo "# Unity Project" >> README.md | |
fi | |
wget --quiet -o .gitignore -c "https://gist.githubusercontent.com/sunsided/366d7b6e4e8c3df14fea9b9c3f628d6f/raw/2c7616106d102595aae673e02a944bb1fdbee778/.gitignore" | |
wget --quiet -o .gitattributes -c "https://gist.githubusercontent.com/sunsided/366d7b6e4e8c3df14fea9b9c3f628d6f/raw/2c7616106d102595aae673e02a944bb1fdbee778/.gitattributes" | |
echo "Enabling Git-LFS ..." | |
git lfs install | |
echo "Adding standard files ..." | |
git add .gitignore .gitattributes ./README.md | |
echo "Setup done." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
UNITY_BASE_PATH="$HOME/Unity" | |
MERGE=$(find $UNITY_BASE_PATH -type f -name UnityYAMLMerge | sort -r | head -n1) | |
$MERGE "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To make it work, download the
git-init-personal-unity.sh
script e.g. to~/.local/bin/git-init-personal-unity
, adjust the user configuration values and make it executable. Also, download theunity-merge
file to the similar directory, e.g.~/.local/bin/unity-merge
.When run from a new Unity project directory, it will:
.gitignore
file suitable to suppress all unneeded files on Linux, when using JetBrains Rider, and for Unity in general,.gitattributes
file for use with Git-LFS,README.md
file.Having local user configuration isn't always needed, but comes in handy when you do work with different credentials on different machines. See this Gist for the
.gitignore
and.gitattributes
files.