Module 4: Remote Collaboration
Cloning and Remotes
Cloning and remotes
A remote is another copy of a repository. Most teams use a hosted remote as the shared source of truth. Cloning copies the repository and automatically creates a remote named origin.
git clone https://github.com/example/project.git
cd project
git remote -vRepresentative output
origin https://github.com/example/project.git (fetch)
origin https://github.com/example/project.git (push)If you created a local repository first, connect it to a remote manually.
git remote add origin https://github.com/example/project.git
git remote -vRepresentative output
origin https://github.com/example/project.git (fetch)
origin https://github.com/example/project.git (push)Remote names
origin is a convention, not a requirement. Fork-based workflows may also use upstream for the original project and origin for your fork.
Key idea
Your local branches and remote-tracking branches are different. A name like origin/main is Git's latest local memory of the remote branch. Use git fetch to update that memory.