A simple, beginner-friendly cheat sheet for everyday Git and GitHub commands.
git config --global user.name "Your Name"
# Sets your name for all commits
git config --global user.email "you@example.com"
# Sets your email for all commits
git config --list
# Lists all current Git config settingsgit init
# Creates a new Git repo in the current folder
git clone https://github.com/user/repo.git
# Copies a GitHub repo to your local systemgit status
# Shows which files are new, modified, staged, or ignoredgit add filename.ext
# Stages a single file
git add .
# Stages ALL modified and new files in the current foldergit commit -m "Describe what you did"
# Saves your staged changes with a messageExample:
git commit -m "Fixed login bug and added validation"git pull
# Gets the latest changes from the remote repo (e.g., GitHub)
git push
# Sends your committed changes to the remote repogit branch
# Lists all branches in your local repo
git branch new-branch
# Creates a new branch (but does NOT switch to it)
git checkout branch-name
# Switches to an existing branch
git checkout -b new-branch
# Creates AND switches to a new branch
git merge branch-name
# Merges another branch into your current onegit reset filename.ext
# Unstages a file (keeps the changes)
git checkout -- filename.ext
# Reverts the file to its last committed state (loses changes)
git reset --hard
# WARNING: Resets ALL changes and staging β use carefully!git log
# Shows full commit history with author, date, message
git log --oneline
# Shows a compact one-line-per-commit historygit status
git add .
git commit -m "Your message"
git pull
git push- Always use
git statusto know whatβs going on. - Use meaningful commit messages.
- Use branches for new features or fixes.
- Pull before you push to avoid conflicts.