Stage 5 · Lesson 6 of 8
Merge and rebase
There are two ways to bring branches back together. A (git merge) joins the two histories with a merge commit, a commit with two parents. If nothing has changed on the other side, Git just moves the label forward instead, called a .
Either way it records exactly what happened. A (git rebase main) replays your branch's commits on top of the latest main. The history ends up in one straight line, but your commits get new hashes.
Many teams rebase their own to bring it up to date, then merge it through a . The golden rule: never rebase commits other people have already pulled. Interactive rebase (git rebase -i) lets you tidy your own commits before review.
Common traprebasing a shared branch and forcing everyone else into a mess.
A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- BookFreePro Git
Scott Chacon and Ben Straub
The free official Git book; chapters 2 and 3 cover everything in this stage properly
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
The version control lecture teaches Git from its data model upwards, which makes commands make sense
Practise
Keep handy
Also worth your time
- roadmap.sh: Git and GitHubGo deeper
A map of Git and GitHub topics, from basics to hooks, submodules and Actions