Your First Commit
Getting Started
Preview
Start a repository
cd my-project\ngit init\n\n# check status\ngit statusStage and commit
git add . # stage all changes\ngit add index.html # stage one file\n\ngit commit -m "Add homepage"\n\n# see history\ngit log --onelineThe workflow
WORKING FILE → (git add) → STAGING → (git commit) → HISTORYAvoid tracking junk
# .gitignore: files Git should never track\nnode_modules/\n.env\n*.log\nconfig.local.phpStatus checkpoints
git status # what changed\nGit diff # the actual changes\ngit log --oneline -5 # recent commitsUndoing mistakes
git restore file.txt # discard uncommitted changes\n git reset --soft HEAD~1 # undo last commit, keep changes\n git log --oneline # find the hash you want to return toTip: Commit when a logical unit of work is complete (a feature, a fix), not when you feel tired. Message: imperative, like "Add login form".
This is a free preview lesson
Enroll in the Git & GitHub for Beginners to unlock every lesson, lesson PDF guides, quizzes and your certificate - and start creating your own pieces today.