Skip to content

jagtaprathmesh19/GitHub-Commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 

Repository files navigation

πŸš€ GitHub Commands β€” Practical Guide

Project Scenario: ShopStream

ShopStream is a collaborative e-commerce web application. This guide walks through the entire Git lifecycle β€” from setup ➜ feature development ➜ collaboration ➜ release ➜ debugging.


🧩 How to Read This Guide

Each command follows this pattern:

Command Use Case (ShopStream example) What the command actually does


πŸ”Ή Phase 1: Project Setup & Configuration

Initialize & Connect Repositories

git init

Start the ShopStream project from scratch Initializes a new Git repository in the current folder.


git config

Set 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.


πŸ”Ή Phase 2: Feature Development

(Example: Shopping Cart)

Branching & Development

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.


Tracking Changes

git status

Check modified cart files Shows staged, unstaged, and untracked files.


git diff

Review 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.


πŸ”Ή Phase 3: Collaboration & Sync

git fetch

Check teammate updates without merging Downloads remote changes only.


git pull

Update your branch with team changes Fetches and merges in one step.


git push

Upload your shopping-cart feature to GitHub Publishes local commits to remote.


git stash

Pause feature work to fix an urgent bug Saves uncommitted changes temporarily.


git stash pop

Resume paused work Restores the latest stash.


πŸ”Ή Phase 4: Inspecting History

git log

View 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 shortlog

See contribution summary per developer Groups commits by author.


πŸ”Ή Phase 5: Integration & Release

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.


πŸ”Ή Phase 6: Undo, Fixes & Debugging

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 bisect

Find the exact commit that caused a bug Uses binary search to isolate failures.


βš™οΈ Essential Git Flags (Quick Reference)

πŸ”Ή Setup & Configuration

git config --global

Applies settings to all repositories.

git clone --depth 1

Shallow clone (latest commit only).

git remote -v

Shows remote URLs.


πŸ”Ή Feature Development

git checkout -b feature

Create + switch branch.

git status -s

Short status output.

git add -p

Stage selected code chunks.

git commit -a

Auto-stage modified files.

git commit --amend

Edit last commit.


πŸ”Ή Collaboration

git fetch --prune

Remove deleted remote branches.

git pull --rebase

Replay commits cleanly.

git push -u

Set upstream branch.

git push --force

Overwrite remote history (use carefully).

git stash -u

Stash tracked + untracked files.


πŸ”Ή History & Cleanup

git log --oneline --graph

Compact visual history.

git blame -L 10,20 file

Blame specific lines.

git clean -n

Preview cleanup.

git clean -fd

Delete untracked files & folders.

git reflog

Recover lost commits or branches.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors