ShopStream is a collaborative e-commerce web application. This guide walks through the entire Git lifecycle β from setup β feature development β collaboration β release β debugging.
Each command follows this pattern:
Command Use Case (ShopStream example) What the command actually does
git initStart the ShopStream project from scratch Initializes a new Git repository in the current folder.
git configSet your developer identity for ShopStream commits Configures username, email, and preferences (local or global).
git clone [url]Download the ShopStream repository to a new machine Copies the entire remote repository including history and branches.
git remote add [name] [url]Connect your local ShopStream repo to GitHub Allows pushing and pulling code from a remote server.
git branch [name]Create a feature branch (shopping-cart)
Creates an isolated workspace for new features.
git checkout [name]Switch to the shopping-cart branch Updates your working directory to that branch.
git switch [name]Safely switch branches (modern method)
A clearer alternative to checkout for branch switching.
git statusCheck modified cart files Shows staged, unstaged, and untracked files.
git diffReview code changes before saving Displays line-by-line differences.
git add [file]Stage Cart.js for commit
Moves changes to the staging area.
git commit -m "message"Save shopping cart logic to history Creates a snapshot of staged changes.
git restore [file]Discard broken experimental changes Reverts files back to last committed state.
git fetchCheck teammate updates without merging Downloads remote changes only.
git pullUpdate your branch with team changes Fetches and merges in one step.
git pushUpload your shopping-cart feature to GitHub Publishes local commits to remote.
git stashPause feature work to fix an urgent bug Saves uncommitted changes temporarily.
git stash popResume paused work Restores the latest stash.
git logView ShopStream commit history Shows commits, authors, dates, and messages.
git show [commit]Inspect a specific commit Displays exact code changes.
git blame [file]Find who wrote a problematic line Shows author and commit per line.
git shortlogSee contribution summary per developer Groups commits by author.
git merge [branch]Merge shopping-cart into main Combines branch histories.
git rebase [branch]Update feature branch with latest main code Rewrites commits for clean linear history.
git tag [name]Mark ShopStream v1.0 release Creates a version reference.
git reset --soft [commit]Undo commit but keep changes Moves HEAD while preserving staged code.
git reset --hard [commit]Fully revert to a safe state Deletes all local changes.
git revert [commit]Safely undo a production bug Creates a new commit that cancels an old one.
git cherry-pick [commit]Apply a specific fix to another branch Copies a single commit.
git bisectFind the exact commit that caused a bug Uses binary search to isolate failures.
git config --globalApplies settings to all repositories.
git clone --depth 1Shallow clone (latest commit only).
git remote -vShows remote URLs.
git checkout -b featureCreate + switch branch.
git status -sShort status output.
git add -pStage selected code chunks.
git commit -aAuto-stage modified files.
git commit --amendEdit last commit.
git fetch --pruneRemove deleted remote branches.
git pull --rebaseReplay commits cleanly.
git push -uSet upstream branch.
git push --forceOverwrite remote history (use carefully).
git stash -uStash tracked + untracked files.
git log --oneline --graphCompact visual history.
git blame -L 10,20 fileBlame specific lines.
git clean -nPreview cleanup.
git clean -fdDelete untracked files & folders.
git reflogRecover lost commits or branches.