Git
Perform git operations in the workspace.
Common operations
- Status:
git status - Log:
git log --oneline -20 - Diff:
git diff - Staged diff:
git diff --cached - Add files:
git add <file>orgit add -A - Commit:
git commit -m "message" - Branch:
git branch -a - Switch branch:
git checkout <branch>orgit switch <branch> - Create branch:
git checkout -b <branch> - Pull:
git pull - Push:
git push - Stash:
git stash/git stash pop - Blame:
git blame <file> - Search history:
git log --grep="pattern" - Find who changed a line:
git log -p -S "text" -- <file>
Tips
- Always check
git statusbefore committing - Use
git diff --statfor a summary of changes - Use
git log --oneline --graphfor branch visualization