Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    GITGit & GitHub

    Basics: from file to commit

    • Why version control?
    • From working tree to commit
    • Read history and differences
    • .gitignore and useful commit messages

    Branches and merging

    • Branches and HEAD
    • Merge: fast-forward and three-way
    • Resolve merge conflicts
    • Park work temporarily with stash

    Undo without losing work

    • Restore and unstage
    • Reset: soft, mixed and hard
    • Revert or reset?
    • Amend and reflog: rescue recent work

    Remotes and GitHub Flow

    • Remotes, push and tracking
    • Fetch, pull and rejected pushes
    • GitHub Flow: complete project
    Git & GitHub

    Undo without losing work · Lesson 10 of 15

    Reset: soft, mixed and hard

    See exactly how each mode moves HEAD, staging and files.

    12 minutes2 games

    reset moves the branch name and HEAD to another commit, then decides what to do with staging and files. soft preserves both, mixed (the default) resets staging, and hard resets staging and files.

    --soft: HEAD only

    --mixed: + staging

    --hard: + working tree

    Git
    git init -q -b main
    echo "one" > app.txt
    git add app.txt
    git commit -q -m "One"
    echo "two" >> app.txt
    git commit -q -am "Two"
    git reset --soft HEAD~1
    git status -s

    --soft HEAD~1 is useful for rebuilding the last commit: history moves back while its change remains staged. Mixed leaves it unstaged. Hard makes tracked files match the target, discarding later edits.

    Important

    Pause before reset --hard: inspect status and verify the reference. It does not ask for confirmation, and uncommitted tracked work can disappear. Prefer revert on published history.

    Quick question

    Which mode moves HEAD only and leaves changes staged?

    Interview question

    Explain reset using Git's three trees.

    Exercise

    Make two commits, soft-reset one step, and print short status.

    Expected output: M app.txt

    Git
    git init -q -b main
    echo "one" > app.txt
    git add app.txt
    git commit -q -m "One"
    echo "two" >> app.txt
    git commit -q -am "Two"
    git status -s

    Learn more from

    • Git: git-resetgit-scm.com
    • Atlassian: Reset, checkout and revertatlassian.com

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousRestore and unstageNextRevert or reset?
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.