Git
Use this page to keep practical Git commands, workflows, and recovery notes.
Store several users in git credential manager.
- Configure a namespace for each account
git config --global credential.personal.namespace personal
git config --global credential.personal.name Edmund Wong
git config --global credential.personal.email changechun.huang@gmail.com
git config --global credential.personal.helper manager- Using a different namespace name for work.
git config --global credential.work.namespace work
git config --global credential.work.name Edmund Wong
git config --global credential.work.email edmundwongcc@sjmresorts.com
git config --global credential.work.helper manager- Tell each local repository which namespace to use
git config credential.namespace personal
//or git config credential.namespace workCommon checks
powershell
git status
git branch
git log --oneline --decorate -10Review changes
powershell
git diff
git diff --staged
git show HEADBranch workflow
powershell
git switch main
git pull
git switch -c feature/my-changeCommit workflow
powershell
git add .
git commit -m "Describe the change clearly"Useful recovery commands
powershell
git restore path/to/file
git restore --staged path/to/file
git stash push -m "work in progress"
git stash list
git stash popNotes
- Prefer small, focused commits.
- Review
git diffbefore every commit. - Avoid destructive commands unless you are certain about the rollback path.