Core Git commands for version control
| Command | Description |
|---|---|
git init | Initialize new repository |
git clone <url> | Clone repository |
git config --global user.name "Name" | Set username |
git config --global user.email "email" | Set email |
| Command | Description |
|---|---|
git status | Check repository status |
git add <file> | Stage specific file |
git add . | Stage all changes |
git commit -m "message" | Commit staged changes |
git commit -am "message" | Add and commit in one step |
| Command | Description |
|---|---|
git remote add origin <url> | Add remote repository |
git push origin <branch> | Push to remote |
git push -u origin main | Push and set upstream |
git pull | Fetch and merge from remote |
git fetch | Download remote changes without merging |
| Command | Description |
|---|---|
git log | View commit history |
git log --oneline | Compact history view |
git diff | Show unstaged changes |
git diff --staged | Show staged changes |
git show <commit> | Show commit details |