KEMBAR78
Top 40 Git Commands | PDF
0% found this document useful (0 votes)
8 views3 pages

Top 40 Git Commands

This document summarizes the top 40 most commonly used Git commands, organized into categories such as Setup & Configuration, Status & Info, Staging & Committing, Branching, Remote Repositories, Undo & Fix, and Search & Logs. It provides essential commands for initializing repositories, managing branches, and handling commits. The guide serves as a quick reference for users to effectively utilize Git.

Uploaded by

alex.soufi59
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Top 40 Git Commands

This document summarizes the top 40 most commonly used Git commands, organized into categories such as Setup & Configuration, Status & Info, Staging & Committing, Branching, Remote Repositories, Undo & Fix, and Search & Logs. It provides essential commands for initializing repositories, managing branches, and handling commits. The guide serves as a quick reference for users to effectively utilize Git.

Uploaded by

alex.soufi59
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

GIT

Top 40 commands
This is the summary of the top 40 most used git commands which helps the reader to start using
git right away.

Setup & Configuration

1. git config --global user.name "Your Name"


2. git config --global user.email "you@example.com"
3. git config --list
4. git init — Initialize a new Git repo
5. git clone <repo-url> — Copy a remote repo

📁 Status & Info

6. git status — View current repo status


7. git log — See commit history
8. git show — Show commit details
9. git diff — See code differences
10. git blame <file> — Show who changed each line

📦 Staging & Committing

11. git add <file> — Stage a file


12. git add -A — Stage all changes
13. git commit -m "message" — Commit staged changes
14. git commit -am "message" — Add & commit tracked files
15. git reset <file> — Unstage a file
16. git reset --hard — Undo all uncommitted changes
17. git restore <file> — Discard changes to a file
18. git restore --staged <file> — Unstage a file

🌳 Branching

19. git branch — List branches


20. git branch <name> — Create a new branch
21. git checkout <name> — Switch branch
22. git checkout -b <name> — Create and switch to branch
23. git branch -d <name> — Delete a branch
24. git merge <branch> — Merge a branch
25. git rebase <branch> — Reapply commits on another base

🌍 Remote Repositories
26. git remote -v — View remotes
27. git remote add origin <url> — Add a remote
28. git fetch — Download from remote
29. git pull — Fetch + merge from remote
30. git push — Push to remote
31. git push -u origin <branch> — Push and set upstream
32. git remote remove <name> — Remove remote

🧹 Undo & Fix

33. git revert <commit> — Create a new commit that undoes a previous one
34. git reset --soft HEAD~1 — Undo last commit (keep changes staged)
35. git reset --mixed HEAD~1 — Undo commit (keep changes unstaged)
36. git clean -f — Remove untracked files

🔍 Search & Logs

37. git grep "text" — Search inside tracked files


38. git log --oneline — Compact commit view
39. git shortlog — Summary of commit authors
40. git tag — List tags

You might also like