Git Tutorial for Beginners — From Zero to PR

Git Tutorial for Beginners — From Zero to PR

Team08 October 2024 Blog, DevTools, Tutorials

Install Git, make your first repo, understand commits and branching, work with remotes, and open a clean pull request.

Install & Configure

# install (macOS)
brew install git

# identity
git config --global user.name "Your Name"
git config --global user.email you@example.com

First Repo & Commits

mkdir hello-git && cd hello-git
git init
echo "hello" > README.md
git add README.md
git commit -m "feat: initial commit"

Branching & Merging

git checkout -b feature/login
# ...edit files...
git add .
git commit -m "feat(login): ui"
git switch main
git merge feature/login

Remote & Pull Request Flow

git remote add origin https://github.com/<you>/hello-git.git
git push -u origin main
# Open GitHub and create a Pull Request from your branch to main

Rebase vs Merge

  • Merge: preserves history; adds a merge commit.
  • Rebase: linear history; rewrites commits (avoid rebasing shared branches).