🔰 Beginners
Command | Description | Example |
---|---|---|
git init | Initializes a new Git repository | git init my-project |
git clone | Copies an existing repository | git clone https://github.com/user/repo.git |
git add | Stages changes for the next commit | git add file.txt |
git commit | Records staged changes | git commit -m "Initial commit" |
git status | Displays working directory status | git status |
git push | Sends local commits to remote | git push origin main |
⚙️ Intermediate
Command | Description | Example |
---|---|---|
git branch | Lists, creates, or deletes branches | git branch feature-login |
git checkout | Switches branches or restores working tree | git checkout feature-login |
git merge | Integrates changes from another branch | git merge feature-login |
git log | Shows commit history | git log --oneline |
git stash | Temporarily shelves uncommitted changes | git stash save "WIP: login feature" |
git tag | Creates, lists, or deletes tags | git tag v1.0.0 |
🚀 Advanced
Command | Description | Example |
---|---|---|
git rebase | Reapplies commits on top of another base tip | git checkout feature && git rebase main |
git cherry-pick | Applies a specific commit from another branch | git cherry-pick a1b2c3d4 |
git bisect | Uses binary search to find the commit that broke code | git bisect start; git bisect bad; git bisect good v1.0
|
git reflog | Records updates to local references | git reflog |
git submodule | Manages nested repositories within a parent project | git submodule add https://github.com/user/lib.git libs/lib
|
git filter-branch | Rewrites branches by filtering commit history | git filter-branch --tree-filter 'rm -f secrets.txt' HEAD
|