New! Explore our Programming Academy and AI Tutor - learn to code from scratch, free to start. Explore Now
Programming› Git› Remotes and Collaboration

Remotes and Collaboration

💻 Git

Push, pull and clone, and work with pull requests without breaking shared history.

Lesson 7 of 9 Tutorial
0 of 9 completed

A remote is a shared copy of the repository. Most teams use GitHub, GitLab or Bitbucket as the remote.

By the end of this lesson you can:
  • Clone a repository.
  • Push and pull safely.
  • Understand pull requests and review.

Clone

Cloning downloads the full history and sets origin as the default remote.

git clone https://github.com/user/project.git
cd project
git remote -v

Push and Pull

Push sends your commits. Pull fetches and integrates changes from the remote. Pull before you start work to reduce conflicts.

git push -u origin feature/login-form
git pull --rebase origin main

Pull Requests

A pull request proposes merging a branch. Keep it small, describe the change and how you tested it, and respond to review comments with new commits.

Warning Never force-push a shared branch. It rewrites history for everyone else and can erase their work.

Practice

  1. Clone a public repository and inspect its remotes.
  2. Push a feature branch to your own fork.
  3. Write a pull request description with a summary and test notes.

Hands-on exercise

Create a repository on GitHub, then:
1. Add it as a remote named origin.
2. Push your main branch.
3. Create a branch locally, commit a change and push it with -u.

Recap

Remotes share history. Clone once, push your branches and pull before starting new work.

Example

git clone https://github.com/user/project.git
cd project
git remote -v

Exercises

Exercise 1. First push Medium
Create a repository on GitHub, then:
1. Add it as a remote named origin.
2. Push your main branch.
3. Create a branch locally, commit a change and push it with -u.
Git exercise-1.txt
Expected Output
Both branches appear on the remote.

Lesson Nav

Lesson sections