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

    Branches and merging · Lesson 7 of 15

    Resolve merge conflicts

    Read markers, choose the right result, and know when to abort.

    12 minutes2 games

    A conflict is not a failure; it is a question for a human when two branches change the same area. <<<<<<< marks the current side, ======= divides it, and >>>>>>> marks the incoming side.

    merge reports a conflict

    Understand both intents

    Edit and remove markers

    add then commit

    Git
    git init -q -b main
    echo "blue" > color.txt
    git add color.txt
    git commit -q -m "Base"
    git switch -q -c feature
    echo "green" > color.txt
    git commit -q -am "Green"
    git switch -q main
    echo "navy" > color.txt
    git commit -q -am "Navy"
    git merge feature
    cat color.txt

    Write the intended final version, test it, then git add file to mark it resolved and commit. Use git merge --abort if the merge was a mistake.

    Important

    Never choose ours or theirs blindly; both may matter. Search for <<<<<<< before committing.

    Quick question

    What marks a file resolved?

    Interview question

    How can a team reduce conflicts?

    Exercise

    Create a conflict in answer.txt, resolve it as both, commit and print the file.

    Expected output:
    Auto-merging answer.txt
    CONFLICT (content): Merge conflict in answer.txt
    Automatic merge failed; fix conflicts and then commit the result.
    both
    Git
    git init -q -b main
    echo "base" > answer.txt
    git add answer.txt
    git commit -q -m "Base"

    Learn more from

    • GitHub Docs: Resolve conflictsdocs.github.com
    • Git: git-mergegit-scm.com

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousMerge: fast-forward and three-wayNextPark work temporarily with stash
    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.