Git Rebase

When working on a feature, we may need to get updates from the main development branch.

We could merge the development branch into ours, but the commit history will not show a list of our changes, they will be mixed together with the others.

A rebase will take our branch and replay commits on top of the latest dev work.

With our branch checked out: git rebase dev

Ours/Theirs

When rebasing, if a conflict is encountered, the files to resolve are uncommitted.

You can use git checkout --ours/theirs to use the file from one branch or the other.

When rebasing, keep in mind that --ours refers to the base branch, and --theirs refers to the one we're rebasing.

This is opposite of ours/there's during merging, where --ours refers to the currently checked out branch that we're merging into.

Ours/theirs does not refer to my code/their code. It's just the base branch in both situations, but this can be conceptually confusing.

Level
Topics