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 branch + git switch — Working with Branches

0m 00s

Parallel Lines of Development

A branch is a lightweight, movable pointer to a commit. The default branch is usually called main (or master).

git branch              # list all branches (* = current)
git branch feature-x    # create a new branch
git switch feature-x    # switch to it
git switch -c hotfix    # create AND switch in one step (modern)
git checkout -b hotfix  # older syntax, same result

Why branch?

  • Work on a new feature without breaking main
  • Fix a bug in isolation
  • Experiment freely — discard the branch if it doesn't work
  • Multiple developers work in parallel without stepping on each other

Branches are cheap in Git — they're just a 41-byte file pointing to a commit hash. Create them freely.

Your Task

Starting from main with one commit, create and switch to a new branch called feature. Then create feature.txt and commit it.

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.