Overview
Git is a distributed version control system used to track changes in source code. These commands cover a typical day-to-day workflow.
Inspect and prepare changes
git status
git diff
git diff --staged
git log --oneline --decorate -10
Stage and commit
git add path/to/file.php
git add .
git commit -m "Describe the change"
Review git status and staged differences before committing. Avoid adding environment files, credentials, generated secrets or large temporary files.
Branches and remotes
git switch -c feature/example
git switch main
git fetch
git pull
git push -u origin feature/example
The exact workflow depends on the team's branching and review process. Understand merge and rebase behavior before rewriting shared history.