Skip to main content
Let’s continue our discussion on Git by covering remote repositories — the central place where team members share and combine their work. When you initialize a Git repository on your laptop, that’s a local Git repository. In a team, each developer typically has their own local repository with a copy of the project files. For example, one person might edit main.py, another db.py, someone else cache.py, and so on.
A diagram showing four side-by-side local Git repositories (My Laptop, Mark’s, Aditi’s, Lee’s), each containing a "my-application" folder with the same file list. Colored user icons appear next to certain files (e.g., main.py, db.py, cache.py) to indicate individual changes.
When everyone’s changes are ready, those local commits need to be consolidated in a central place — a remote Git repository. Remotes can be hosted on the public internet (for example, GitHub or GitLab), or on servers inside your own network (self-hosted Git servers). The remote holds a combined history and becomes the single source of truth that developers push to and pull from. Example layout of a remote repository (logical view):
How merging works
  • When team members push commits, the remote stores that history.
  • Git can automatically merge changes when edits touch different parts of the same file.
  • If two commits change the same line in the same file, a merge conflict occurs and must be resolved manually.
  • After conflicts are resolved and pushed, everyone can pull the merged history and obtain the latest combined copy.
What is a remote Git repository and how do you set one up?
  • Self-hosted: Install Git on a server and expose it via git daemon, SSH, or smart HTTP(s).
  • Hosted services: Use GitHub, GitLab, Bitbucket, etc., which provide web UIs, access control, pull requests, CI/CD integrations, and more.
  • Private instances: Run a private GitLab or other Git hosting inside your network for greater control.
Table: Remote hosting options at a glance
Git is the distributed version control system (the tool). GitHub and GitLab are hosted services that provide remote repositories, web interfaces, access controls, pull requests, and many extras that simplify team collaboration.
Preparing and pushing local code to a remote repository
  1. Initialize the local repo, add files, and commit:
  1. Create a remote repository on your hosting service (for example, via the GitHub UI at https://github.com/new). Save the repository URL shown by the hosting service.
  2. Add the remote locally and push:
Important notes:
  • When writing commands in documentation, use backticks around placeholders like git remote add <name> <url> so MDX doesn’t interpret angle brackets.
  • Remote names are aliases for convenience. origin is the conventional default name for the primary remote, but you can name remotes anything (e.g., github, gitlab, upstream). You can also configure multiple remotes for the same repository.
Many hosting services now use main as the default branch name instead of master. Check your service’s default branch and adjust commands (for example, git push -u origin main) accordingly.
Cloning and default remote setup
  • When a new developer needs a local copy, they use git clone with the remote URL. Cloning copies the repository and automatically configures a remote named origin.
  • After cloning, git remote -v shows configured remotes:
  • Since origin is set up automatically on clone, you generally do not need to run git remote add after cloning.
Common workflows: pushing, pulling, and updating
  • Make changes, stage, and commit locally:
  • Push commits to the remote:
  • Get other people’s changes by pulling from the remote:
git pull is shorthand for git fetch followed by git merge (or git fetch + git rebase when configured). It updates your local branch with commits from the remote. Quick reference table: common commands Resolving merge conflicts
  • If two people edit different lines, Git usually merges automatically.
  • If the same line is changed by two people, Git marks a conflict in the file and you must edit the file, resolve the conflict markers, stage the resolved file, and commit.
  • After resolving conflicts and pushing, other team members can pull the updated, conflict-free history.
Next steps and practice
  • Practice the full lifecycle: initialize a repo, create a remote, push, clone, pull, and intentionally create & resolve a simple merge conflict.
  • Apply these concepts to a real project and collaborate with teammates or loop through a small CI workflow.
Links and references We’ll cover more advanced Git topics and workflows in future lessons and hope to offer an in-depth Git course soon.

Watch Video

Practice Lab