Work the GitHub way — feature branches, pull requests for code review, the gh CLI to skip browser trips, and keeping your branch up to date with main.
Why: you never commit straight to main on a shared project. Instead you branch off, do your work in isolation, and propose merging it back. This keeps main always working and gives teammates a chance to review. Note: a "feature branch" is just a normal Git branch named after the work it holds.
Make sure you start from an up-to-date main
git switch maingit pullCreate and switch to a branch for your work
git switch -c add-login-form…commit as usual, then push the branch up to GitHub
git push -u origin add-login-formWhy: a pull request (PR) asks "please merge my branch into main" and is where code review happens — teammates comment, request changes, and approve before anything ships. It is GitHub's most important feature. Note: a PR is the GitHub name for what GitLab calls a merge request — same idea.
After pushing a branch, GitHub prints a "Create a pull request" link — open it, or go to the repo → "Pull requests" tab → "New pull request"
Fill in a clear title and a description of WHAT changed and WHY. Reviewers comment line-by-line; push more commits to the same branch and the PR updates automatically — no need to open a new one.
When approved, click "Merge pull request", then delete the branch.
Why: gh is GitHub's official command-line tool. It lets you open, view, and merge pull requests without leaving the terminal — a big time-saver once you are comfortable. Note: run gh auth login once to connect it to your account.
One-time setup: sign in
gh auth loginOpen a PR for the current branch, filling in title and body interactively
gh pr createSee open PRs, and check one out locally to test it
gh pr listgh pr checkout 42Merge a PR and delete its branch in one go
gh pr merge 42 --squash --delete-branchWhy: while you work, main moves on as other PRs merge. Bringing those changes into your branch early avoids a painful pile-up of conflicts at merge time. Note: merging main into your branch is the simplest, safest option while you are learning.
Get the latest main from GitHub
git switch maingit pullBring it into your feature branch
git switch add-login-formgit merge mainResolve any conflicts, commit, then push the update
git push