MANUAL
Working with Git
01 / THE BASICS
What Git does for you.
Git saves every version of your app. If something goes wrong, you can revert to a version that worked. Your AI assistant uses Git too, so it helps if you know the four words that crop up time and again.
01 / Four words
- Commit: a saved version of your changes, with a brief description.
- Push: send your commits to GitHub.
- Pull: fetch changes from GitHub to your computer.
- Branch: a separate line of work. You try something out without affecting the working version.
02 / One-off: setting your name
Git includes a name and email address with every commit. Set these up once:
git config --global user.name "Je Naam"
git config --global user.email "jij@voorbeeld.nl"
Please use the email address associated with your GitHub account.
02 / DAILY
Save changes.
Open the terminal in your project folder. Always carry out these four steps in the same order.
03 / See what’s changed
git status
Red indicates files that have been modified but not yet staged. Green indicates files that are ready to be committed.
04 / Prepare your changes
git add .
The dot means: everything in this folder. Then use git status to check that there are no files in there that shouldn’t be shared, such as .env.
05 / Make a commit
git commit -m "Contactformulier toegevoegd"
Jot down briefly what you’ve changed. That way, you’ll be able to find it again later.
06 / Send it to GitHub
git push
07 / Fetch changes
Do you use two computers, or have I changed something? If so, please download the latest version before you start:
git pull
03 / TRY IT OUT SAFELY
Working with a branch.
A branch allows you to try something new without affecting the working version.
08 / Create a branch
git switch -c nieuw-menu
You are now working in the ‘new-menu’ branch. Commit and push as usual. The first time, Git will ask you to carry out an extra step:
git push -u origin nieuw-menu
09 / Back to the main version
git switch main
Do you like the new version? If so, please open a pull request on GitHub to merge the branch. I can review it there before it goes live.
04 / IF THINGS GO WRONG
Return to a previous version.
10 / View history
git log --oneline
On each line, you’ll see a code and a description of a commit.
11 / Discard changes you haven’t yet saved
git restore .
This discards all changes that you haven’t yet staged using git add. You cannot undo this.
12 / Undoing a commit
git revert abc1234
Replace abc1234 with the code from git log --oneline. Git will create a new commit that reverses the previous one. Your history will be preserved.
13 / Ask your AI assistant for help
"Show what has changed since the last commit. Explain what each change does and ask for permission before you commit, push or delete anything."
Good to know
Never use git push --force or git reset --hard unless you know exactly what will be lost. If your AI assistant asks you to use one of these commands, ask first what will be lost.