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

    Remotes and GitHub Flow · Lesson 13 of 15

    Remotes, push and tracking

    Connect a local repository to a shared copy and push a branch safely.

    10 minutes2 games

    A remote is a saved name for another repository's address. origin is merely a convention, not magic. git push -u origin main sends commits and records an upstream, so later git push knows the remote and branch.

    Local main

    push

    tracking origin/main

    shared repository

    Git
    git init -q -b main
    echo "project" > README.md
    git add README.md
    git commit -q -m "Initial project"
    git remote add origin https://example.com/team/app.git
    git remote -v
    git push -u origin main

    origin/main is a local reference to the last known remote main, not a branch you work on directly. Push transfers missing objects and asks the remote to advance its branch. Use SSH or HTTPS according to your organization.

    Important

    A remote URL may identify a service, but never embed a token in repository files or screenshots. Use a credential manager or SSH agent, and inspect git remote -v without exposing credentials.

    Quick question

    What does -u do on the first push?

    Interview question

    Difference between main and origin/main?

    Exercise

    Create a repository and commit, add a remote named origin, then print detailed remotes.

    Expected output:
    origin	https://example.com/app.git (fetch)
    origin	https://example.com/app.git (push)
    Git
    git init -q -b main
    echo "app" > app.txt
    git add app.txt
    git commit -q -m "Start"
    git remote -v

    Learn more from

    • Git: Working with Remotesgit-scm.com
    • GitHub Docs: Managing remote repositoriesdocs.github.com

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousAmend and reflog: rescue recent workNextFetch, pull and rejected pushes
    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.