Git/
Lesson

Until now, all your Git work was local on your computer. That is great for learning, but Git really becomes powerful when you connect your local repositoryWhat is repository?A project folder tracked by Git that stores your files along with the complete history of every change, inside a hidden .git directory. to a remote one. It is like switching from solo mode to multiplayer mode.

Imagine your local repository is your personal notebook. A remote repository is like publishing that notebook in a library where others can read it, contribute to it, and where it is safe even if you lose your notebook.

What is a remote?

A remote is simply a copy of your repositoryWhat is repository?A project folder tracked by Git that stores your files along with the complete history of every change, inside a hidden .git directory. stored elsewhere, usually on the internet. When you clone an existing repository or push your local work to a server, you create this connection.

Your Computer              Remote Server (GitHub)
      |                              |
Local Repo  <--- push --->  Remote Repo
      |        <-- fetch --          |
   Work                         Shared
02

The most popular remote services

You have several options for hosting your remote repositories:

ServiceStrengthsIdeal for
GitHubMost popular, excellent open-source communityOpen source, portfolios, collaboration
GitLabOpen source platform, integrated CI/CDEnterprise, DevOps, private hosting
BitbucketAtlassian integration (Jira, Confluence)Teams already using Atlassian
Azure DevOpsMicrosoft ecosystem integrationMicrosoft-centric enterprises
AI pitfall
AI tools often assume you are using GitHub. If you ask "how do I set up a remote?", they will generate GitHub URLs and commands. The Git commands are the same across all platforms, only the URL format differs. Always substitute the actual URL of your hosting provider.
03

OriginWhat is origin?The combination of protocol, domain, and port that defines a security boundary in the browser, like https://example.com:443.: the default remote

When you clone a repositoryWhat is repository?A project folder tracked by Git that stores your files along with the complete history of every change, inside a hidden .git directory., Git automatically assigns the name origin to the remote you cloned from. It is just a convention, but everyone follows it:

# This command automatically creates a remote named 'origin'
git clone https://github.com/user/project.git

You can verify this connection:

git remote -v
# origin  https://github.com/user/project.git (fetch)
# origin  https://github.com/user/project.git (push)

The name origin is so universal that every developer immediately understands what you are referring to.

04

Local vs remote: key differences

AspectLocalRemote
LocationYour computerServer on the internet
VisibilityPrivate to youShared with the team
SpeedInstant (all operations)Depends on network connection
HistoryCompleteComplete (it is Git!)
CollaborationSoloMulti-user
05

The typical remote workflow

Here is what your daily life with Git and remotes looks like:

# 1. Work locally on a branch
git add . && git commit -m "Add login form"

# 2. Push your work to the remote
git push origin my-branch

# 3. Other developers retrieve your changes
git pull origin main

# 4. Collaboration via pull requests, code review
#    (GitHub/GitLab web interface)
06

Why use remote repositories?

Automatic backup. Your code is safe on a server. If your computer breaks down, you can reclone and pick up exactly where you left off.

Smooth collaboration. Multiple developers can work on the same project without overwriting each other's work. Git manages conflicts intelligently.

Sharing and open source. You can publish your code so others can use it, study it, or contribute to it. It is the heart of open source.

CI/CDWhat is ci/cd?Continuous Integration and Continuous Deployment - automated pipelines that test your code on every push and deploy it when tests pass. and automation. Remotes can trigger automated tests, deployments, and quality checks on every push.

07

Git is distributed

This is important: when you clone a remote repositoryWhat is repository?A project folder tracked by Git that stores your files along with the complete history of every change, inside a hidden .git directory., you don't just download the current files. You download the entirety of Git history, every commitWhat is commit?A permanent snapshot of your staged changes saved in Git's history, identified by a unique hash and accompanied by a message describing what changed., every branch, everything.

# This command downloads all history
git clone https://github.com/user/repo.git

# You can now work offline
# You have the same power as if you were connected
Practical implication
Even if the remote server goes down, any clone contains enough information to recreate the entire repository.
08

Your first remote

If you start a project locally and want to push it to GitHub:

# 1. Create an empty repository on GitHub (without README)

# 2. In your local project, add the remote
git remote add origin https://github.com/username/my-project.git

# 3. Push your code and set upstream tracking
git push -u origin main

The -u (or --set-upstream) configures your local branch to track the remote branch. After that, you can simply use git push without specifying origin main.

09

Quick reference

CommandWhat it does
git remote -vList all remotes with their URLs
git remote add name urlAdd a new remote
git clone urlCopy a remote repository locally
git pushSend your commits to the remote
git pullRetrieve and merge remote changes
git fetchRetrieve changes without merging