Remotes and Collaboration
💻 GitPush, pull and clone, and work with pull requests without breaking shared history.
A remote is a shared copy of the repository. Most teams use GitHub, GitLab or Bitbucket as the remote.
- 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 -vPush 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 mainPull 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.
Practice
- Clone a public repository and inspect its remotes.
- Push a feature branch to your own fork.
- 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
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.
Expected Output
Both branches appear on the remote.
Lesson Nav
Git Course
0/9 lessons completed
- 1 Why Version Control Matters Tutorial
- 2 Your First Repository Tutorial
- 3 Staging and Committing Tutorial
- 4 History, Diffs and Logs Tutorial
- 5 Branching Tutorial
- 6 Merging and Resolving Conflicts Tutorial
- 7 Remotes and Collaboration Tutorial
- 8 Undoing Mistakes Safely Tutorial
- 9 Project: A Team Workflow Project