Lesson 2 · Unit 04
Collaboration
Rejected pushes, pull, force and pull requests
What you practise
- A rejected push and why, pull with merge vs rebase,
--force-with-leaseand when force is acceptable, pull requests as a conversation around a branch
Try a question from this lesson
Pick one
Ana and Bo both clone when main is at commit A. Ana pushes B. Bo, who has not fetched, commits C on top of A and pushes. What should the server do?
Correct answer
Reject it: Bo must bring in B first
Why
Moving main from B to C would drop B from the branch, because C does not contain it. A normal push may only fast-forward the remote branch, so the server refuses and git tells Bo to fetch first.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Push only fast-forwards
A push asks the other repository to move its branch to your commit. It agrees only if that is a fast-forward: your commit must already contain theirs.
If someone pushed first, bring their commits into your branch with git pull, then push again. Pull is a fetch plus either a merge or a rebase.
origin: A --- B main
you: A --- C main
C does not contain B: push rejected11 more exercises in the app
- 3× type the answer
- 1× fill the blanks
- 4× multiple choice
- 1× true or false
- 1× order the lines
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.