This will help you get a quick setup with a new Unity project and GIT LFS.
- Setup new Project
- Clone Existing Project
- Move to another repository
- Add a new staged file to LFS
- Related info
-
Edit > Project Settings:
- [Category: Editor] Asset Serialization / Mode: “Force Text”
- [Category: Version Control ] Mode: “Visible Meta Files”
-
File > Save Project
Note, png file requires a user agent to download (used 'Firefox on Linux')
- Open command prompt (Win+R -> 'cmd')
- Copy the following commands and paste/execute them all at once
git init --initial-branch=main
git lfs install
curl https://raw.githubusercontent.com/rboonzaijer/unity-quickstart/main/Project/-%20Git%20lfs%20check/pre-commit -o ".git/hooks/pre-commit"
curl -L -A "Mozilla/5.0 (X11; Linux i686; rv:140.0) Gecko/20100101 Firefox/140.0" -O https://media.githubusercontent.com/media/rboonzaijer/unity-quickstart/main/Project/git-lfs-logo.png
curl https://raw.githubusercontent.com/rboonzaijer/unity-quickstart/main/Project/{.gitattributes,.gitignore} -O
curl https://raw.githubusercontent.com/rboonzaijer/unity-quickstart/main/Project/-%20Git%20lfs%20check/{README.md,pre-commit,pre-commit-install.ps1} -o "- Git lfs check\#1" --create-dirs
curl https://raw.githubusercontent.com/rboonzaijer/unity-quickstart/main/Project/Assets/Editor/{UnityEditorMenuSaveAll.cs,UnityPostBuildCallbacks.cs} -o "Assets\Editor\#1" --create-dirs
curl https://raw.githubusercontent.com/rboonzaijer/unity-quickstart/main/Project/-%20Build%20Scripts/Build{-WindowsDefault,WindowsLZ4,WindowsLZ4HC,Config,Profile}.ps1 -o "- Build Scripts/Build#1.ps1" --create-dirs
curl https://raw.githubusercontent.com/rboonzaijer/unity-quickstart/main/Project/{.gitconfig,.gitconfig-update-version.bat} -O
curl https://raw.githubusercontent.com/rboonzaijer/unity-quickstart/main/Project/.gitconfig---%5Brun%20update-version.bat%5D -o ".gitconfig---[run update-version.bat]"
.gitconfig-update-version.bat
- Go into Unity again, and press CTRL+SHIFT+ALT+S (Or: File > Save All)
git add .
git commit -m "initial"# Optionally, see which files are tracked with LFS (can be done before the commit)
git lfs ls-filesgit remote add origin ssh://git@{host}:{port}/{new-repo}.git
git push -u origin mainYou can check in your repository if the png is stored with lfs.
git clone {repo}GIT LFS will already be enabled (if it was enabled in the repository) and it should already download all the LFS-tracked files, but if you need it:
# Download lfs objects for current branch
git lfs fetch
# Download lfs objects for all branches
git lfs fetch --all- Navigate to
Project/- Git lfs check/pre-commit-install.ps1Rightclick > Run with PowerShell
Example: from Github to Gitlab, including all LFS objects
# Clone the repository as a mirror into "repo-mirror"
git clone --mirror [email protected]:rboonzaijer/source-unity-project.git repo-mirror
cd repo-mirror
# Download all LFS objects for all refs (not just current branch)
git lfs fetch --all
# Point the "origin" remote to the new GitLab repo
git remote set-url origin [email protected]:rboonzaijer/target-unity-project.git
# First, push all LFS files (for all branches/tags) to the new remote
git lfs push --all origin
# Now push all refs (branches, tags, etc.) to the new remote
git push --mirror origin# Optional (perhaps the file is already added to the staged files)
git add "Assets/My file.large"
# or add all files: git add .
# Track if with lfs (will be added to .gitattributes)
git lfs track -- "Assets/My file.large"
# Add .gitattributes
git add .gitattributes
# Add the file and renormalize
git add --renormalize -- "Assets/My file.large"
# now commit...
