Git Basics
Every professional developer uses Git. You do not need to master it — but you need to understand what it does and why your team uses it. This page covers the minimum.
Quick start: Install Git or GitHub CLI
Section titled “Quick start: Install Git or GitHub CLI”Option A: GitHub CLI (Recommended)
Section titled “Option A: GitHub CLI (Recommended)”Windows:
winget install GitHub.cliOr download from: cli.github.com
macOS:
brew install ghLinux:
sudo apt install gh # Debian/UbuntuAuthenticate:
gh auth loginFollow the prompts → choose GitHub.com → HTTPS → Login with browser.
Verify:
gh --versionOption B: Git (Full version control)
Section titled “Option B: Git (Full version control)”Windows: Download from git-scm.com
macOS:
xcode-select --installLinux:
sudo apt install gitConfigure:
git config --global user.name "Your Name"git config --global user.email "your.email@xjtlu.edu.cn"Authenticate:
gh auth login # GitHub CLI handles Git auth tooVerify:
git --versionNext: Connect to AI coding tools
Section titled “Next: Connect to AI coding tools”Once Git is installed, you can use it with AI coding tools:
- OpenCode Desktop — Standalone AI coding app with GitHub Copilot integration, multiple AI models (Claude, GPT-4o), and autonomous agent mode
- GitHub Copilot — VS Code extension with inline completions and chat
- Cursor — VS Code-like editor with built-in AI agent
See the full comparison: AI Coding Tools
Watch: Git and GitHub in 100 seconds
Section titled “Watch: Git and GitHub in 100 seconds”Start here — 100 seconds, everything you need to know at a glance.
What is version control?
Section titled “What is version control?”Version control is a system that records every change you make to your code. You can see who changed what, when, and why. You can go back to any earlier version at any time.
Without version control: one person rewrites a file, the old version is gone. Two people edit the same file at the same time, one overwrites the other. You cannot trace why something broke.
With Git: every change is saved. Every person has a full copy of the history. Conflicts are caught and merged deliberately.
Why Git specifically?
Section titled “Why Git specifically?”Git is the industry standard. GitHub (where you store and share your code) is built on Git. Every professional team you join will use Git. AI coding tools (GitHub Copilot, Cursor, Claude Code) all integrate with Git. Learning the basics now means you speak the same language as every developer you will ever work with.
The four things you must know
Section titled “The four things you must know”Branch
Section titled “Branch”A branch is an isolated copy of your codebase where you can work safely without affecting everyone else.
Why it matters: your main branch should always contain working code. You create a new branch for each feature or fix, work on it, then merge it back when it is done and tested.
main ─────────────────────────────────────────────► (always working) └── feature/feeding-log ──► (your work) ──► merge backCommon commands:
git checkout -b feature/feeding-log # create and switch to a new branchgit checkout main # switch back to mainCommit
Section titled “Commit”A commit is a saved snapshot of your changes with a message describing what you did.
Why it matters: commits are the history. Your pathfinder can see exactly what you did and when. “I worked on the app this week” is invisible — a commit with a clear message is permanent evidence of your contribution.
Good commit messages:
feat: add cat profile form with name and photo uploadfix: prevent duplicate feeding entries within 10 minutesdocs: add acceptance criteria to feeding log user storyBad commit messages:
updatechangesasdfghThe command:
git add . # stage all changed filesgit commit -m "feat: add feeding log form" # save the snapshotPush sends your commits from your local machine to GitHub so the rest of the team can see your work.
Why it matters: code on your laptop only is not code your team or pathfinder can see. Push at the end of every working session.
git push # send commits to GitHubgit push origin feature/feeding-log # push a specific branchPull downloads the latest changes from GitHub to your local machine.
Why it matters: before you start working, always pull. Otherwise you are working on an old version and will get conflicts when you try to push.
git pull # get latest changes from GitHubThe daily loop
Section titled “The daily loop”pull → work → commit → pushgit pull— get everyone else’s latest changes- Write your code
git add .thengit commit -m "what you did"— save your workgit push— share it with the team
Repeat. That is all of it.
Watch: Git in depth (~13 min)
Section titled “Watch: Git in depth (~13 min)”If you want to understand the concepts properly before using the commands, this longer walkthrough is worth it.
Can’t access YouTube? Search for “Git and GitHub introduction” or “Git explained beginners” on Bilibili or any platform you can reach — there are good short videos in both English and Chinese.
Minimum viable Git setup
Section titled “Minimum viable Git setup”If your team is not yet using Git properly, fix this now. The minimum:
- One shared GitHub repository (created by the Technical Lead)
- Everyone cloned —
git clone <repo-url> - Each developer works on their own branch
- Merge to
mainonly when the feature works
This is enough for your sprint. You do not need Pull Requests, Actions, or automated tests yet — those come later.
If something goes wrong
Section titled “If something goes wrong”Git errors are normal. Common ones and what to do:
| Error | What it means | Fix |
|---|---|---|
merge conflict | Two people edited the same lines | Open the file, find the conflict markers <<<<, decide which version to keep, then commit |
rejected — non-fast-forward | Someone else pushed before you | Run git pull first, then try git push again |
nothing to commit | No changes since your last commit | You are already up to date |
detached HEAD | You checked out a commit directly | Run git checkout main to get back |
When in doubt: do not force-push to main. Ask a teammate or search the exact error message.
Was this page helpful?