You will initialize a repository, stage and commit changes, branch, and push to a remote. By the end you will have a clean, recoverable history and understand the staging-area model that makes Git powerful.

Learning Objectives

  • Track changes with the staging area and meaningful commits.
  • Branch and switch context safely.
  • Push to and pull from a remote.
  • Time: ~2 hours · Difficulty: Beginner · Prereqs: Git installed and a GitHub account.

Architecture Overview

Environment Setup

You will need: Git 2.4x and a remote (GitHub) repository.

Before you begin: set your identity with git config --global user.name/email.

Step-by-Step Execution

01
Initialize and make the first commit

The staging area lets you craft exactly what goes into each commit.

git init && git add . && git commit -m "initial commit"
02
Branch for a change
git switch -c feature/login && git commit -am "add login"
03
Connect a remote and push
$ git remote add origin [email protected]:tyfsadik/app.git && git push -u origin feature/login
branch 'feature/login' set up to track 'origin/feature/login'.

Progress So Far

Testing & Validation

git log --oneline --graph --all && git status

You should see your commits on the branch and a clean working tree. If so, your history is tracked and pushed.

Troubleshooting
  • Author unknown: set user.name/user.email before committing.
  • Push rejected: pull/rebase first; the remote has commits you lack.
  • Committed a secret: remove it and rewrite history with git filter-repo, then rotate the secret.

Extension Ideas

Key Results

  • Built a clean, recoverable commit history.
  • Used branches to isolate a change from main.
  • Pushed work to a tracked remote branch.
  • Verified state with log and status.