Imagine you have a feature branch diverged from main. What does rebasing your feature branch onto main do to the commit history?
Think about how rebasing changes the base of your feature branch commits.
Rebasing takes your feature branch commits and replays them on top of the latest commit of main, creating a straight, linear history without merge commits.
You have a main branch with commits A-B-C and a feature branch with commits D-E diverged from B. You run git rebase main on feature. What does git log --oneline --graph show for feature branch?
Rebased commits get new commit IDs and appear on top of main's latest commit.
After rebasing, commits D and E are replayed on top of commit C, creating new commits D' and E' that form a linear history.
When rebasing a feature branch onto main, you encounter conflicts. Why does this happen?
Think about what happens when commits are replayed on a different base.
Rebasing re-applies each commit on top of main. If both branches changed the same lines, conflicts occur that must be resolved manually.
You want to keep your project history linear and easy to read. Which workflow should you use?
Think about which command rewrites history to be linear.
Rebasing rewrites commits to create a straight line of history, avoiding merge commits and making the log easier to follow.
Which situation is a best practice reason to avoid rebasing a branch?
Consider the impact of rewriting history on collaboration.
Rebasing rewrites commit history. If others use the branch, rewriting history can cause confusion and conflicts. Avoid rebasing public/shared branches.