Git & GitHub Command Cheat Sheet: From Basics to Advanced

Whether you’re a beginner just getting started with Git or an experienced developer who needs quick reference, this Git & GitHub Cheat Sheet has you covered.

YASH PATEL1/13/20263 min read12 views
GitHubGit Commands
Git & GitHub Command Cheat Sheet: From Basics to Advanced

🔹 Basic Workflow

=> These are the everyday Git commands you’ll use to track changes and sync with GitHub:

  • git init → Initialize a new Git repository
  • git clone [url] → Download a project from GitHub
  • git add [file] → Stage a specific file for commit
  • git add . → Stage all changes for commit
  • git commit -m "message" → Commit staged changes
  • git push origin [branch] → Push commits to remote
  • git pull origin [branch] → Pull latest changes

🔹 Branch Masters

=> Branching lets you work on features independently without affecting main code:

  • git branch → List all branches
  • git branch [name] → Create new branch
  • git checkout [branch] → Switch to branch
  • git merge [branch] → Merge branch into current
  • git branch -d [branch] → Delete branch locally
  • git push origin --delete [branch] → Delete remote branch

🔹 History Explorers

=> Explore and understand the history of your codebase:

  • git log --oneline → Compact commit history
  • git log --graph --oneline --all → Visual commit tree
  • git show [commit] → Show changes in specific commit
  • git diff → Show unstaged changes
  • git diff --staged → Show staged changes
  • git blame [file] → See who changed each line

🔹 Undo Artists

=> Made a mistake? No worries, Git’s got your back:

  • git reset --soft HEAD^ → Undo commit, keep changes staged
  • git reset --hard HEAD^ → Remove last commit completely
  • git checkout -- [file] → Discard changes in working directory
  • git revert [commit] → Create new commit that undoes changes
  • git clean -fd → Remove untracked files & directories

🔹 GitHub Collaborators

=> For open-source contributions or working in teams:

  • git fork → Create a personal copy of repository
  • git remote add upstream [url] → Add original repo as upstream
  • git fetch upstream → Get updates from original repo
  • git push -u origin [branch] → Push & set upstream branch
  • git pull --rebase upstream main → Update fork with rebase

🔹 Stash & Cleanup

=> When you need to pause work without committing:

  • git stash → Temporarily store changes
  • git stash pop → Restore most recent stash
  • git stash list → View all stashes
  • git stash drop → Delete most recent stash
  • git prune → Remove unreachable objects

🔹 Tagging & Releases

=> Tags are great for marking releases:

  • git tag [name] → Create lightweight tag
  • git tag -a [version] -m "message" → Annotated tag
  • git push origin --tags → Push all tags to remote
  • git tag -d [name] → Delete local tag
  • git push origin --delete tag [name] → Delete remote tag

🔹 Advanced Tools

=> Powerful commands for debugging and history management:

  • git bisect → Binary search to find buggy commit
  • git rebase -i [commit] → Interactive rebase (rewrite history)
  • git cherry-pick [commit] → Apply specific commit to current branch
  • git reflog → Show reference log (lifesaver for recovery)
  • git worktree add → Add additional working trees

🔹 Configuration

=> Personalize Git to fit your workflow:

  • git config --global user.name "Name" → Set global username
  • git config --global user.email "email" → Set global email
  • git config --global core.editor "code --wait" → Use VS Code as editor
  • git config --global alias.co checkout → Create shortcuts
  • git config --list → Show all configurations

# Final Thoughts

Git is powerful, but it can feel overwhelming when you’re just starting out. Bookmark this cheat sheet and use it as a quick reference whenever you’re stuck.

Hire Yash Patel — Full Stack Web Developer

About Me

Welcome to my portfolio! I am Yash Patel, a Full Stack Web Developer based in India, specializing in Next.js, React, Node.js, and MongoDB. I design and develop fast, scalable, and responsive web applications for clients worldwide. With expertise in the MERN stack, API development, and SaaS solutions, I help businesses bring their digital products to life efficiently, professionally, and affordably.

My approach focuses on building high-quality code that is maintainable, SEO-friendly, and optimized for performance. Whether it’s a custom web application, ecommerce platform, or a portfolio website, I ensure every project meets modern web standards and provides an excellent user experience across devices and browsers.

Services

I offer a wide range of services including full stack web development, frontend and backend programming, RESTful API integration, database design, and web performance optimization. From small business websites to complex SaaS applications, I deliver scalable solutions tailored to each client’s unique needs. I also specialize in responsive UI/UX design, ensuring your users enjoy smooth navigation and fast load times.

Why Hire Me?

By choosing to work with me, you gain a reliable developer who prioritizes quality, speed, and efficiency. I emphasize clean, maintainable code, SEO best practices, and performance optimization. My goal is to help businesses grow their online presence and achieve measurable results through high-performing websites and applications.

Contact

Interested in working together? Contact me today to discuss your project requirements. Let’s build your website or web application with a developer who delivers professionalism, reliability, and measurable impact. Whether it’s a startup, business, or personal project, I am ready to help you achieve your web goals.