linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Chapters
  • How it works
  • Lessons
  • Knowledge base
  • Interview prep
home/git/kb/Remote repositories

kb/remote

Remote repositories: push, pull, fetch, remotes

Remote repositories in Git with push, pull, and fetch: origin, upstream, and `git remote add`. The difference between fetch and pull, and why `git push --force-with-lease` is safer than `--force`. Tracking branches, SSH keys, and GPG-signed commits and tags.

  • force-pushForce push

    `git push --force` overwrites the remote history with yours. `git push --force-with-lease` does the same, but refuses if someone pushed there after your last fetch. Always use `--force-with-lease`.

  • clonegit clone

    Creates a local copy of a remote repository. Under the hood: `init` + add origin + `fetch` the full history + `checkout` the default branch. The first command you run on any project you did not create yourself.

  • fetchgit fetch

    Downloads updates from a remote but **does not touch** your local branches. Updates only refs/remotes/origin/. A safe command: after fetch you can see what arrived and decide what to do with it.

  • pullgit pull

    Fetches updates from a remote repository and merges them into the current branch. Essentially `git fetch` + `git merge` (or + `git rebase` with `--rebase`). The most confusing command for beginners.

  • pushgit push

    Sends local commits to a remote repository and updates the branch there. If the remote received commits from someone else after your last pull, push will refuse until you synchronize.

  • remote-cmdgit remote

    Manages the list of URLs your repository is connected to. After `clone` there is one remote named `origin` by default. You can add a second one (`upstream` for fork flow), remove remotes, or rename them.

  • tracking-branchTracking branch

    The link between a local branch and a remote one: "this branch of mine follows that remote branch." Enables `git pull`/`push` without arguments and `git status` messages like "ahead 3, behind 2."

  • upstream-vs-originupstream vs origin

    Two conventional remote names. `origin` is where you cloned from (usually your fork). `upstream` is the "real" project you forked. This is just a convention: nothing is magic, both names can be renamed.

Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies