Godot Git Setup

From Stridr
Revision as of 12:57, 17 May 2026 by Nathans1987 (talk | contribs) (Created page with "<br /> = 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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Godot + Git + Gitea Project Template (Linux)[edit | edit source]

A reusable workflow for setting up a new Godot project with Git and pushing it to a blank Gitea repository using HTTPS.


Prerequisites[edit | edit source]

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[edit | edit source]

1. Initialize Git Repository[edit | edit source]

git init

What it does:

  • Creates a hidden .git folder
  • Turns the current folder into a Git repository
  • Starts tracking version history

Useful when:

  • Starting any new project

2. Create Godot .gitignore[edit | edit source]

cat > .gitignore << 'EOF'
.godot/
.import/
.export/
export_presets.cfg
EOF

What it does:

  • Creates a .gitignore file
  • Prevents machine-generated or temporary files being committed

Ignored files explained[edit | edit source]

  • .godot/ → Godot 4 cache/import data
  • .import/ → legacy import cache
  • .export/ → export temp files
  • export_presets.cfg → local export settings

Why ignore these:

  • Reduces repo size
  • Avoids merge conflicts
  • Keeps commits clean

3. Stage All Files[edit | edit source]

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[edit | edit source]

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 movement
  • Implement inventory system
  • Fix wall jump bug

Bad commit messages:

  • stuff
  • update
  • asdf

Future you will thank present you.


5. Add Remote Repository[edit | edit source]

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[edit | edit source]

git branch -M main
git push -u origin main

git branch -M main[edit | edit source]

  • Renames current branch to main

git push -u origin main[edit | edit source]

  • Uploads commits to remote
  • -u sets upstream so future pushes only need git push

After first push:

git push

is enough.


Save HTTPS Credentials (Optional but recommended)[edit | edit source]

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[edit | edit source]

After making changes:

git add .
git commit -m "Describe changes"
git push

Typical workflow:

  1. Code
  2. Test
  3. Commit
  4. Push

Branching[edit | edit source]

Useful for testing features safely.

Create new branch[edit | edit source]

git checkout -b feature-double-jump

What it does:

  • Creates branch
  • Switches to it immediately

Now you can experiment without touching main.


Switch branches[edit | edit source]

git checkout main

or:

git checkout feature-double-jump

Moves between branches.


View branches[edit | edit source]

git branch

Current branch has *

Example:

* main
  feature-double-jump

Merge branch into main[edit | edit source]

Switch to main first:

git checkout main

Merge:

git merge feature-double-jump

This combines work into main.


Delete merged branch[edit | edit source]

git branch -d feature-double-jump

Keeps repo tidy.


Useful Commands[edit | edit source]

Check status[edit | edit source]

git status

Shows:

  • modified files
  • staged files
  • current branch

Most used Git command.


View commit history[edit | edit source]

git log --oneline

Compact history view.

Example:

4f8a1d2 Add dash mechanic
2a8c114 Initial commit

See changed files[edit | edit source]

git diff

Shows unstaged changes.


Undo unstaged changes[edit | edit source]

git restore filename

Danger: discards local edits.


Unstage file[edit | edit source]

git restore --staged filename

Removes from staging without deleting changes.


Recommended Solo Dev Workflow for Godot[edit | edit source]

For small solo projects:

  • Commit often
  • Push daily or after milestones
  • Use branches for risky features
  • Keep main stable/playable

Example branch naming:

  • feature-inventory
  • feature-wall-jump
  • bugfix-animation
  • refactor-state-machine

Quick Reference Cheat Sheet[edit | edit source]

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.