Tools

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

TaskCommand
Record changesgit add .git commit -m "message"
Fetch from remotegit pull
Push to remotegit push
Create branchgit checkout -b branch-name
Switch branchgit checkout branch-name
Stash changesgit stash
Restore stashgit stash pop
Discard changesgit restore filename
Check statusgit status
View historygit log --oneline

Troubleshooting

  • Fix commit messagegit commit --amend -m "new message"
  • Undo last commitgit reset --soft HEAD~1 (keeps changes)
  • Merge conflict — Resolve <<<<<<< and >>>>>>> manually, then git addgit commit

Start with add, commit, and push. The rest will come with practice.