Last Update: 2023-07-06
Using Git with DST Modding
Git is a powerful version control system that can significantly improve your Don't Starve Together mod development workflow. This guide will walk you through setting up Git for your DST mods, establishing best practices, and integrating it with your development process.
Why Use Git for DST Modding?
- Version History: Track changes to your mod over time
- Branching: Work on new features without affecting your stable release
- Collaboration: Make it easier for multiple people to work on the same mod
- Backup: Keep your mod code safe in remote repositories
- Issue Tracking: Manage bugs and feature requests effectively
- Release Management: Tag specific versions for release
Setting Up Git for DST Mods
Installing Git
- Download and install Git from the official website
- Verify installation by opening a terminal/command prompt and typing:
git --version
Configuring Git
Set up your identity for commits:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Creating a Git Repository for Your Mod
-
Navigate to your mod's directory:
cd path/to/your/mod
-
Initialize a new Git repository:
git init
-
Create a
.gitignore
file to exclude unnecessary files:# DST mod specific ignores
_tmp/
*.bak
*.tmp
# OS specific files
.DS_Store
Thumbs.db
# Editor files
.vscode/
*.sublime-workspace
.idea/ -
Add your files to Git:
git add .
-
Make your first commit:
git commit -m "Initial commit of my DST mod"
Git Workflow for DST Modding
Basic Workflow
-
Make changes to your mod files
-
Stage changes:
git add .
Or for specific files:
git add modmain.lua scripts/prefabs/myitem.lua
-
Commit changes with a descriptive message:
git commit -m "Add new item prefab with custom effects"
-
View your commit history:
git log
Using Branches
Branches are useful for developing new features without affecting your main mod:
-
Create a new branch:
git checkout -b new-feature
-
Make changes and commit them to the new branch
-
Switch back to the main branch:
git checkout main
-
Merge your changes when ready:
git merge new-feature
Tagging Releases
When you release a new version of your mod:
git tag -a v1.0.0 -m "Version 1.0.0 - Initial release"
View all tags:
git tag
Remote Repositories
GitHub Integration
-
Create a GitHub account if you don't have one
-
Create a new repository on GitHub
-
Connect your local repository:
git remote add origin https://github.com/yourusername/your-mod-repo.git
-
Push your code to GitHub:
git push -u origin main
Cloning an Existing Mod Repository
To work on an existing mod repository:
git clone https://github.com/username/mod-repo.git
cd mod-repo
Best Practices for DST Mod Version Control
Commit Messages
Write clear, descriptive commit messages:
- Use present tense ("Add feature" not "Added feature")
- First line should be a concise summary (50 chars or less)
- Optionally follow with a blank line and detailed description
Example:
Add custom crafting recipe for magic staff
- Added recipe to custom crafting tab
- Balanced ingredient requirements
- Added recipe unlock condition based on sanity
Branching Strategy
A simple but effective branching strategy for mods:
main
- Stable, released versionsdevelop
- Working branch for next release- Feature branches - For individual features
- Hotfix branches - For urgent fixes to released versions
Managing Mod Versions
-
Update your
modinfo.lua
version number -
Commit the change:
git commit -m "Bump version to 1.1.0"
-
Tag the release:
git tag -a v1.1.0 -m "Version 1.1.0"
-
Push tags to GitHub:
git push origin --tags
Integrating Git with VSCode
If you're using VSCode for DST modding:
- Open your mod folder in VSCode
- Access Git features through the Source Control tab (Ctrl+Shift+G)
- Stage, commit, and push changes directly from the interface
- View diffs, history, and branches visually
Handling Mod Assets with Git
Large Files
For large binary files (like animations or textures):
-
Consider using Git LFS (Large File Storage)
-
Install Git LFS:
git lfs install
-
Track large file types:
git lfs track "*.tex"
git lfs track "*.zip"
git lfs track "*.bin" -
Commit the
.gitattributes
file:git add .gitattributes
git commit -m "Configure Git LFS"
Collaborative Modding with Git
Pull Requests
For collaborative mods:
- Contributors fork the repository
- Make changes in their fork
- Submit pull requests to the main repository
- Mod owner reviews and merges changes
Issue Tracking
Use GitHub Issues to:
- Track bugs in your mod
- Manage feature requests
- Organize your development roadmap
- Communicate with users and contributors
Troubleshooting Git Issues
Resolving Merge Conflicts
When Git can't automatically merge changes:
-
Open the conflicted files (marked with
<<<<<<<
,=======
, and>>>>>>>
) -
Edit the files to resolve conflicts
-
Save the files
-
Stage the resolved files:
git add .
-
Complete the merge:
git commit
Reverting Changes
To undo commits:
# Undo last commit but keep changes
git reset --soft HEAD~1
# Undo last commit and discard changes
git reset --hard HEAD~1
# Revert a specific commit (creates a new commit)
git revert commit_hash
See also
- VSCode Setup - For setting up VSCode with Git integration
- First Mod - For creating your first DST mod
- Troubleshooting Guide - For resolving common modding issues
- API Updates - For tracking changes to the DST API