Git and GitHub for FiveM developers
This is the lesson that saves your afternoon. You have a working resource from Module 02. One careless edit, one corrupted file, one "I'll just try this", and it's gone. Git is the safety net. The mental model is trivial: git takes snapshots of your folder, and each snapshot is called a commit. Git is the version control tool doing the work; GitHub is the website that hosts a copy of your code online. GitHub Desktop is the button-based way to start using git right now, no terminal required, and later in this lesson you also see the exact same actions typed as raw git commands, useful once you need to clone someone else's resource or work over SSH on a server.
Build it
Install GitHub Desktop and sign in
Go to github.com/apps/desktop (the old desktop.github.com link still redirects here) and click Download now to get the installer for your operating system (Windows or macOS). Run it and accept the defaults.
On first launch it asks you to sign in. Click Sign in to GitHub.com, authorise in the browser tab that opens, then return to the app. When it asks for your name and email, use anything you like; these become the author shown on your commits.
You land on the home screen with three buttons: Clone a repository, Create a new repository, and Add an existing repository. The third one is the one you want next.
Turn qu_hello into a repository
Use either safe path to add your folder:
Home screen: Add an existing repository from your hard drive
Menu: File -> Add local repository
Browse to your resources/qu_hello folder. GitHub Desktop says the directory does not appear to be a git repository and offers a create a repository link. Click it, then fill the dialog:
Name: qu_hello (must match the folder name)
Description: my first FiveM resource
Local path: the parent of qu_hello (already filled in)
Initialize with README: ticked
Git Ignore: None (you write a custom one in Step 3)
License: None
Click Create repository. On the main screen the left pane lists every file inside qu_hello, all ticked, ready for the first snapshot. The README that the init step just generated is in that list too, which is fine: you write the FiveM .gitignore in the next step before you ever commit, so nothing you want excluded gets locked into history first.
Write a .gitignore for FiveM
A .gitignore lists patterns git will not track. It is the difference between a clean repo and one full of .DS_Store, editor config, and streaming assets nobody wants in version control.
In GitHub Desktop click Repository -> Open in Visual Studio Code (or open the folder in your editor by hand). Create a new file in the root of qu_hello called .gitignore and paste this:
# Editor / OS cruft
.DS_Store
Thumbs.db
.vscode/
.idea/
*.swp
*.bak
*.tmp
*.log
# Secrets (never commit these)
*.env
config.secret.*
# Node / build artefacts, if a resource uses NUI tooling later
node_modules/
dist/
build/
*.tsbuildinfo
# FiveM things that do not belong in a resource repo
cache/
logs/
# Large streaming assets -> keep these in a separate asset-pack repo
stream/**/*.ytyp
stream/**/*.ydr
stream/**/*.ydd
stream/**/*.ytd
Save. Back in GitHub Desktop the changes list updates: .gitignore is now tracked, and anything matching its patterns disappears from the list.
Make your first commit
Look at the bottom-left of GitHub Desktop. There are two fields: Summary (required, a one-line description under 70 characters in the imperative tense) and Description (optional longer prose). Skip the description for now and type this summary:
feat: add /hello command and manifest
Click the blue Commit to main button. That is a snapshot. Open the History tab (top-left) and you see one entry: your commit, your name, the timestamp, and every file captured. Click any file to see exactly what was stored.
Now make a second commit the right way. Open server/main.lua and add one line at the top:
print('qu_hello loaded')
Save. The Changes tab shows server/main.lua with exactly one green added line in the diff on the right. Commit it:
chore: log when resource starts
Check History: two commits now. Click the new one and confirm only that single line was captured.
Branch, then revert
A branch is a parallel line of commits that does not affect main until you merge it. In the top bar click Current branch: main, click New Branch, type a new name in the "Create a Branch" dialog, and click Create Branch:
feature/cooldown
You are now on the new branch. Add a line to the top of server/main.lua and commit it:
local lastHealAt = 0
feat: scaffold heal cooldown
Switch back to main (branch dropdown -> pick main) and open server/main.lua. The line is gone. That is not a bug, that is branches working: main is untouched. Switch back to feature/cooldown and the line returns.
When a branch breaks something you cannot explain, you do not guess. Open History, find the commit where the code last worked, right-click it, and choose Revert changes in commit. That creates a new commit undoing the bad one, history intact. Inspect the diff first so you can see exactly which lines were the culprit.
Publish to GitHub as a private repo
Right now the repo is local only. If your drive dies, your commits die with it. In the top bar click Publish repository and fill the dialog:
Name: qu_hello (pre-filled, leave it)
Keep this code private: ticked
Organization: None
Click Publish Repository. A few seconds later it is live at github.com/<your-username>/qu_hello, private, visible only to you. From now on: after any local commit click Push origin to sync up; before a session on another machine click Fetch origin then Pull origin to pull down.
Keep reading the full lesson
Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.
- If something went wrong
- What you can do now
- Try it yourself
The remainder of Git and GitHub for FiveM developers is available to FiveM School members.