Git Practical Guide: From Zero to Daily Use

Git Practical Guide: From Zero to Daily Use

Jasper

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
2
git config --global user.name "Jasper"
git config --global user.email "jasperzpzhang@gmail.com"

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
2
3
4
git clone git@github.com:yourname/your-repo.git
cd your-repo
git status
git remote -v

4) Daily edit and commit flow

1
2
3
4
5
6
7
git pull
git checkout -b feat/add-login-page
# edit files
git status
git add .
git commit -m "feat: add login page"
git push -u origin feat/add-login-page

What this means:

  • pull: get latest code
  • checkout -b: create a branch for your work
  • add + commit: save your checkpoint
  • push: upload branch to remote

5) Branch basics you really use

List branches:

1
2
git branch
git branch -r

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
2
3
git checkout main
git pull
git push

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 status
  • git 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.