Author: matt

Godot 4 – Adding Git/GitLFS to your existing Local Project

Step 1: Initialize Git in Your Project

Navigate to your project directory and initialize a Git repository:

cd /path/to/your/project
git init

Step 2: Add a .gitignore File for Godot

Create a .gitignore file to exclude unnecessary files from being tracked. Here’s a recommended .gitignore for a Godot project:

# Godot specific
.import/
.export/
*.godot
*.mono/

# OS specific
.DS_Store
Thumbs.db

# Compiled files
*.log
*.tmp

Save this file in the root of your project directory.

Add and commit the .gitignore file:

git add .gitignore
git commit -m "Add .gitignore for Godot"

Step 3: Set Up Git LFS

Install and configure Git LFS:

git lfs install

Track specific file types used in Godot:

git lfs track ".png" ".jpg" ".tga" ".wav" ".ogg" ".glb" "*.gltf" "*.blend"

This creates a .gitattributes file in your project. Add and commit it:

git add .gitattributes
git commit -m "Configure Git LFS"

Step 4: Add Your Project Files to Git

Now, add all the project files to the Git repository:

git add .
git commit -m "Initial commit of Godot project"

Step 5: Connect to a Remote Repository (Optional)

If you want to push your project to a remote repository (e.g., GitHub, GitLab), follow these steps:

Create a new repository on your Git hosting platform. Add the remote repository URL:

git remote add origin https://github.com/username/repository.git

Push the repository to the remote:

git push -u origin main

Step 6: Verify Git LFS

Ensure Git LFS is correctly tracking the designated file types:

git lfs ls-files

Final Notes

The .gitignore ensures that generated files and temporary files are not added to your repository.
The .gitattributes ensures large binary files are handled efficiently by Git LFS.
Once set up, collaborate and manage your Godot project effectively with Git and Git LFS!