Section 01
Git & GitHub Notes
Step-by-step commands from class. Copy and paste — keep the order.
Full command flow
git --version git config --global user.name "Your Name" git config --global user.email "you@email.com" mkdir MyFirstRepo && cd MyFirstRepo # create index.html git init git add . git commit -m "first commit: add index.html" git remote add origin https://github.com/USER/MyFirstRepo.git git branch -M main git push -u origin main
1) Verify Git
After install, open a new terminal.
git --version
2) Configure name + email
Use the same email as your GitHub account.
git config --global user.name "Your Name" git config --global user.email "you@email.com" git config --global --list
3) Create folder + file
cd Desktop mkdir MyFirstRepo cd MyFirstRepo # Create index.html with any editor
<!DOCTYPE html> <html> <head><title>My First Repo</title></head> <body> <h1>Hello GitHub!</h1> <p>Pushed by YOUR_NAME</p> </body> </html>
4) init → add → commit
Working → Staging → Repository
git init git status git add . git status git commit -m "first commit: add index.html" git log --oneline
5) Create empty GitHub repo + push
- github.com → New repository → name: MyFirstRepo
- Public
- Do NOT add README / .gitignore (keep empty)
- Copy HTTPS URL
git remote add origin https://github.com/YOUR_USERNAME/MyFirstRepo.git git remote -v git branch -M main git push -u origin main
Daily workflow (after first push)
# edit files git add . git commit -m "update homepage" git push # optional git pull git clone https://github.com/USER/REPO.git
Common errors
git not recognized
Install Git + open a new terminal
auth failed
Login again / Personal Access Token
remote origin already exists
git remote remove origin then add again
non-fast-forward
Repo was not empty (README issue)
Please tell me who you are
Set user.name and user.email