Git Basics

Essential Git commands and setup

Initialize Repository

git init # initialize new repository
git clone  # clone existing repository
git clone   # clone to specific directory

Configuration

git config --global user.name 'Your Name' # set username
git config --global user.email '[email protected]' # set email
git config --list # list all settings
git config user.name # view specific setting

Check Status

git status # show working tree status
git status -s # short status

Add Files

git add filename # stage specific file
git add . # stage all changes
git add *.js # stage all .js files
git add -A # stage all (including deletions)

View Changes

git diff # show unstaged changes
git diff --staged # show staged changes
git diff filename # changes in specific file