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

.gitignore — Ignoring Files

0m 00s

Keeping Secrets and Noise Out of Git

Some files should never be committed: build artifacts, secrets, OS junk. List them in .gitignore:

# .gitignore
node_modules/       # dependency folder
*.log               # all .log files
.env                # environment variables (secrets!)
dist/               # build output
.DS_Store           # macOS metadata
*.pyc               # Python bytecode

Patterns

  • *.log — matches any file ending in .log
  • build/ — matches a directory named build
  • !important.log — exception: don't ignore this file
  • **/*.test.js — matches in any subdirectory
git check-ignore -v secret.txt   # find out why a file is ignored
git status --ignored             # show ignored files too

Your Task

Create a .gitignore that ignores *.log files and the tmp/ directory. Then commit .gitignore and app.txt — the log file and tmp dir should NOT appear in the commit.

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.