Godot Git Setup
Contents
Godot + Git + Gitea Project Template (Linux)
A reusable workflow for setting up a new Godot project with Git and pushing it to a blank Gitea repository using HTTPS.
Prerequisites
Before starting:
- Git is installed (
git --version) - A Godot project already exists
- A blank repository has been created in Gitea
- You are inside your Godot project folder in terminal
Example:
git --version
pwd
ls
Initial Project Setup
1. Initialize Git Repository
git init
What it does:
- Creates a hidden
.gitfolder - Turns the current folder into a Git repository
- Starts tracking version history
Useful when:
- Starting any new project
2. Create Godot .gitignore
cat > .gitignore << 'EOF'
.godot/
.import/
.export/
export_presets.cfg
EOF
What it does:
- Creates a
.gitignorefile - Prevents machine-generated or temporary files being committed
Ignored files explained
.godot/→ Godot 4 cache/import data.import/→ legacy import cache.export/→ export temp filesexport_presets.cfg→ local export settings
Why ignore these:
- Reduces repo size
- Avoids merge conflicts
- Keeps commits clean
3. Stage All Files
git add .
What it does:
- Adds all current files to the staging area
- Prepares them for commit
Think of staging as:
- "These are the files I want included in the next snapshot"
4. First Commit
git commit -m "Initial commit"
What it does:
- Saves a snapshot of staged files into project history
-m means message.
Good commit messages:
Add player movementImplement inventory systemFix wall jump bug
Bad commit messages:
stuffupdateasdf
Future you will thank present you.
5. Add Remote Repository
git remote add origin https://your-gitea-domain.com/username/repository.git
Replace URL with your Gitea repo URL.
What it does:
- Links local project to remote Gitea repo
Definitions:
origin= nickname for remote server
Check remotes:
git remote -v
6. Set Main Branch + Push
git branch -M main
git push -u origin main
git branch -M main
- Renames current branch to
main
git push -u origin main
- Uploads commits to remote
-usets upstream so future pushes only needgit push
After first push:
git push
is enough.
Save HTTPS Credentials (Optional but recommended)
git config --global credential.helper store
What it does:
- Saves HTTPS username/password or token locally after first login
Benefits:
- No repeated login prompts
Stored in:
~/.git-credentials
Security note:
- Stored in plain text
- Fine for personal Linux machine
- Less ideal on shared computers
Daily Workflow / Future Commits
After making changes:
git add .
git commit -m "Describe changes"
git push
Typical workflow:
- Code
- Test
- Commit
- Push
Branching
Useful for testing features safely.
Create new branch
git checkout -b feature-double-jump
What it does:
- Creates branch
- Switches to it immediately
Now you can experiment without touching main.
Switch branches
git checkout main
or:
git checkout feature-double-jump
Moves between branches.
View branches
git branch
Current branch has *
Example:
* main
feature-double-jump
Merge branch into main
Switch to main first:
git checkout main
Merge:
git merge feature-double-jump
This combines work into main.
Delete merged branch
git branch -d feature-double-jump
Keeps repo tidy.
Useful Commands
Check status
git status
Shows:
- modified files
- staged files
- current branch
Most used Git command.
View commit history
git log --oneline
Compact history view.
Example:
4f8a1d2 Add dash mechanic
2a8c114 Initial commit
See changed files
git diff
Shows unstaged changes.
Undo unstaged changes
git restore filename
Danger: discards local edits.
Unstage file
git restore --staged filename
Removes from staging without deleting changes.
Recommended Solo Dev Workflow for Godot
For small solo projects:
- Commit often
- Push daily or after milestones
- Use branches for risky features
- Keep
mainstable/playable
Example branch naming:
feature-inventoryfeature-wall-jumpbugfix-animationrefactor-state-machine
Quick Reference Cheat Sheet
git add .
git commit -m "message"
git push
git checkout -b new-branch
git checkout main
git merge branch-name
git status
git branch
git log --oneline
End of template.