Git Practical Guide: From Zero to Daily Use
If you can do the steps in this post, you can use Git in real work.
No theory overload, just the commands you actually need.
1) One-time setup
1 | git config --global user.name "Jasper" |
Check it:
1 | git config --global --list |
2) SSH key for GitHub
Create key:
1 | ssh-keygen -t ed25519 -C "jasperzpzhang@gmail.com" |
Show public key:
1 | cat ~/.ssh/id_ed25519.pub |
Copy it to GitHub:Settings -> SSH and GPG keys -> New SSH key
Test connection:
1 | ssh -T git@github.com |
3) Clone and first look
1 | git clone git@github.com:yourname/your-repo.git |
4) Daily edit and commit flow
1 | git pull |
What this means:
pull: get latest codecheckout -b: create a branch for your workadd+commit: save your checkpointpush: upload branch to remote
5) Branch basics you really use
List branches:
1 | git branch |
Switch branch:
1 | git checkout main |
Delete local branch after merge:
1 | git branch -d feat/add-login-page |
6) Rollback without panic
Discard unstaged file changes:
1 | git restore path/to/file |
Unstage a file:
1 | git restore --staged path/to/file |
Undo last commit but keep file changes:
1 | git reset --soft HEAD~1 |
Create a new commit that reverts a bad commit (safe for shared branches):
1 | git revert <commit-hash> |
Find lost commit:
1 | git reflog |
7) Pull and push on main
After PR merge, your normal sync flow is:
1 | git checkout main |
In many teams, main is protected and you push through PR only.
That is normal.
8) My tiny Git checklist
Before pushing, I quickly check:
git statusgit log --oneline -5- commit message style (
feat:,fix:,chore:)
That alone prevents most messy history.
Git gets easy when your flow is consistent.
Use these commands for a week and they become muscle memory.
- Title: Git Practical Guide: From Zero to Daily Use
- Author: Jasper
- Created at : 2026-03-06 17:35:40
- Updated at : 2026-03-06 17:35:40
- Link: https://jasperzpzhang.github.io/git-practical-guide-from-zero-to-daily/
- License: This work is licensed under CC BY-NC-SA 4.0.