Install Git, set your identity, initialize or clone a repository, and learn the working directory → staging → commit loop that everything else builds on.
Why: every commit is stamped with an author name and email — Git needs this before it will let you commit.
Check whether Git is already installed
git --versionSet your identity (stored in ~/.gitconfig)
git config --global user.name "Your Name"git config --global user.email "you@example.com"master to main
git config --global init.defaultBranch mainMacOS / Linux
git config --global core.autocrlf inputWindows
git config --global core.autocrlf trueOverride it for just one repo (stored in .git/config)
git config --local user.email "work@example.com"See everything that's currently configured
git config --listWhy: git init turns a plain folder into a Git repository by creating a hidden .git directory that will store the entire history.
git initA hidden .git/ folder now exists — that's the whole repository
ls -aWhy: cloning downloads a full copy of a remote repository — every file, every commit, every branch — onto your machine.
git clone "url"Clone into a folder with a different name
git clone "url" my-foldergit log --oneline -5Why: this is the core loop of Git. Editing a file changes your working directory, git add stages it, and git commit records it permanently.
1. Edit a file — this only changes your working directory shown as Untracked / Modified
git statusshort status
git status -s2. Stage it — moves it to the staging area
git add "file"Move all files to the staging area
git add .Now changes to be committed
git status -s3. Commit it — records a permanent snapshot
git commit -m "Message"3. Stage modified files and Commit it — records a permanent snapshot
git commit -am "Message"Nothing to commit, working tree clean
git status -sWhy: some files should never be tracked — dependencies, build output, local secrets. .gitignore tells Git which paths to skip. The following are examples:
node_modules/.envdist/*.logWhy: git log is how you read the story of a project — what changed, when, and by whom.
git loggit log --onelinegit log --oneline --graph --allShow the diff introduced by the last commit
git log -p -1Filter by time or author
git log --since="2 weeks ago"git log --author="Your Name"