Remote Collaboration Simulation
What you'll build
A bare remote repository and two local clones representing two developers. You will push from one, pull from the other, and handle a rejected push scenario.
Goals
- Create a bare remote repository
- Clone, push, and pull between local and remote
- Simulate two developers collaborating
- Handle a rejected push by pulling first
Prerequisites
- git init, clone, commit, push, pull
Steps
- 1
Create a bare remote repository
A bare repository has no working directory — it is meant to be pushed to and pulled from, like a GitHub repo. Create one to act as the 'server'.
Codemkdir remote-sim cd remote-sim git init --bare shared.gitExpected result
A bare repository at shared.git that can serve as a remote.
- 2
Developer 1 clones and pushes initial work
Clone the bare repo as developer 1, add a file, commit, and push. This simulates the first developer setting up the project.
Codegit clone shared.git dev1 cd dev1 echo "# Shared Project" > README.md git add . git commit -m "Initial commit" git push origin mainExpected result
dev1 has pushed the initial commit to the shared remote.
- 3
Developer 2 clones and makes changes
Clone the same remote as developer 2. This simulates a second team member joining the project. Make a change, commit, and push.
Codecd ../ git clone shared.git dev2 cd dev2 echo "console.log('hello')" > app.js git add . git commit -m "Add hello script" git push origin mainExpected result
dev2 has added and pushed a new file to the remote.
- 4
Developer 1 pulls the latest changes
Back in dev1, pull the changes that dev2 pushed. This is how collaborators stay in sync — pull before you start working.
Codecd ../dev1 git pull origin main ls # should show app.js nowExpected result
dev1 now has app.js from dev2's push.
- 5
Handle a rejected push
Simulate a rejected push: both developers commit simultaneously. dev1's push is rejected because the remote has dev2's new commit. Pull first, then push.
Code# dev2 makes a change cd ../dev2 echo "v2" > version.txt git add . git commit -m "Add version file" git push origin main # dev1 also makes a change and tries to push cd ../dev1 echo "config" > settings.txt git add . git commit -m "Add settings" git push origin main # REJECTED! # Fix: pull first, then push git pull --rebase origin main git push origin main # succeedsExpected result
After pulling and rebasing, dev1's push succeeds.
Try it yourself
What you learned
You simulated a full remote collaboration: bare repo, two clones, push/pull sync, and a rejected push resolved with pull --rebase. This is the daily workflow of every team using Git.
Related Resources
Related Lessons
- git push & pull
Push, pull, and rejected push handling.
Related Cheatsheets
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.