noknow.dev
Sign inSign up
Course overview
Git — Complete Course
0 / 24 lessons0%

Git Basics

  • git init — Starting a Repository
  • git add + git commit — Your First Commit
  • git status + git log — Reading the State
  • git diff — Seeing What Changed
  • .gitignore — Ignoring Files

Branching

  • git branch + git switch — Working with Branches
  • git merge — Combining Branches
  • Resolving Merge Conflicts
  • Cleaning Up Branches

Remote Repositories

  • git remote — Connecting to a Remote
  • git push — Uploading Your Commits
  • git fetch + git pull — Getting Remote Changes
  • git clone — Copying a Repository

Undoing Changes

  • git restore — Discarding Uncommitted Changes
  • git reset — Moving HEAD Back
  • git revert — Safely Undoing a Commit
  • git stash — Temporarily Saving Work

Rewriting History

  • git commit --amend — Fixing the Last Commit
  • git rebase — Cleaner History
  • git cherry-pick — Applying Specific Commits

Advanced Tools and Workflows

  • git tag — Marking Releases
  • Mastering git log
  • git bisect — Finding Bugs with Binary Search
  • Professional Git Workflows

git add + git commit — Your First Commit

0m 00s

Saving a Snapshot

Creating a commit is a two-step process:

# Step 1: Stage the changes you want to include
git add hello.txt       # stage one file
git add .               # stage everything in the current directory

# Step 2: Save the staged changes as a commit
git commit -m "Add hello.txt"

The -m flag lets you write the commit message inline. Without it, Git opens a text editor.

What's in a commit?

  • A snapshot of all staged files
  • Your name and email (from git config)
  • A timestamp
  • The commit message
  • A pointer to the previous commit (its "parent")
git log             # shows all commits
git log --oneline   # compact: one commit per line
# abc1234 Add hello.txt

Your Task

Two files have been created for you. Stage both files and create a commit with the message "Initial commit".

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.