Course Git & GitHub for Beginners

Your First Commit

Getting Started Preview

Start a repository

cd my-project\ngit init\n\n# check status\ngit status

Stage 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 --oneline

The workflow

WORKING FILE → (git add) → STAGING → (git commit) → HISTORY

Avoid tracking junk

# .gitignore: files Git should never track\nnode_modules/\n.env\n*.log\nconfig.local.php

Status checkpoints

git status              # what changed\nGit diff                # the actual changes\ngit log --oneline -5    # recent commits

Undoing 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 to
Tip: 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.


Discussion

Free preview lesson