Git Commands | Quick Reference for Beginners
Git Development Beginner Commands
When you’re new to Git, it’s easy to forget commands. Here’s a quick reference for daily use.
Basic Flow
git init # Create repository
git add . # Stage changes
git commit -m "message" # Commit
git push # Push to remote
Common Commands
| Task | Command |
|---|---|
| Record changes | git add . → git commit -m "message" |
| Fetch from remote | git pull |
| Push to remote | git push |
| Create branch | git checkout -b branch-name |
| Switch branch | git checkout branch-name |
| Stash changes | git stash |
| Restore stash | git stash pop |
| Discard changes | git restore filename |
| Check status | git status |
| View history | git log --oneline |
Troubleshooting
- Fix commit message —
git commit --amend -m "new message" - Undo last commit —
git reset --soft HEAD~1(keeps changes) - Merge conflict — Resolve
<<<<<<<and>>>>>>>manually, thengit add→git commit
Start with add, commit, and push. The rest will come with practice.