Introduction
Git is a powerful version control tool widely used by developers. Below is a categorized and detailed list of 100+ Git commands.
1. Basic Setup
git init
git config --global
user.name
"Your Name"
git config --global
user.email
"
email@example.com
"
git config --list
git config --global core.editor "code --wait"
2. Repository Management
git clone <repo-url>
git status
git add <file>
git add .
git commit -m "Message"
git commit --amend -m "Updated Message"
3. Branching
git branch
git branch <new-branch>
git branch -d <branch-name>
git checkout <branch-name>
git switch <branch-name>
git switch -c <new-branch>
git merge <branch-name>
git rebase <branch-name>
4. Undoing Changes
git reset --soft HEAD~1
git reset --hard HEAD~1
git revert <commit-hash>
git checkout -- <file>
git clean -f
git stash
git stash pop
5. Collaboration (Remote Operations)
git remote add origin <repo-url>
git remote -v
git fetch
git pull origin <branch>
git push origin <branch>
git push --force
git push --tags
git remote remove origin
6. Tagging
git tag <tag-name>
git tag -a <tag-name> -m "Message"
git show <tag-name>
git push origin <tag-name>
7. Viewing Changes
git diff
git diff --staged
git log
git log --oneline
git show <commit-hash>
git blame <file>
git reflog
git shortlog
8. Advanced History Commands
git cherry-pick <commit-hash>
git cherry
git bisect
git log --graph
git log -p
git describe
git log --author="<author-name>"
git log --grep="keyword"
9. Interactive Features
git rebase -i HEAD~3
git commit --squash <commit-hash>
git commit --fixup <commit-hash>
git rebase --autosquash
git checkout -p
10. Patching and Applying Changes
git format-patch <range>
git apply <patch-file>
git am <patch-file>
git diff > diff.patch
11. Aliases
git config --global
alias.st
status
git config --global
alias.co
checkout
git config --global
alias.br
branch
git config --global
alias.cm
commit
12. Cleanup
git gc
git prune
git clean -fd
13. Submodules
git submodule add <repo-url>
git submodule update
git submodule init
git submodule deinit <path>
14. Hooks
git hooks
git commit-msg
git pre-commit
15. Security
git log --show-signature
git tag -v <tag-name>
16. Worktrees
git worktree add <path> <branch>
git worktree remove <path>
17. Debugging
git fsck
git verify-commit
git verify-tag
18. Ignoring Files
.gitignore
files for directories or patterns.
19. Backup and Restore
git bundle create <file.bundle> <branch>
git bundle verify <file.bundle>
20. Collaboration (Code Review)
git diff --word-diff
git diff <commit1>..<commit2>
git diff --name-only
21. Miscellaneous Commands
git archive
git sparse-checkout
git config --global init.defaultBranch main
git diff-tree
git ls-files
git whatchanged
22. Git Help
git help
git help -a
git help config