
In our case, we roll back to commit E, and save the diff of each commit introduce by the feature branch. When we rebase master "into" feature, what we are really doing is this: "Roll back" to the common ancestor and save the diff What happens during a rebase?Īgain, let's assume the following history: A-B-C feature Let me explain what happens during a rebase. But, the tricky part is identifying the "current" branch. When we run into merge conflicts during a rebase, we are effectively in the middle of a merge, so the rules for git checkout -ours/-theirs from above still apply.

If we want to discard the version of myscript.py that resides in our current branch and keep the version from master, we can use -theirs. git checkout -ours myscript.py Use -theirs to keep the version from the branch being merged inĪnd -theirs accomplishes the opposite. Since we have our feature branch checked out, we can use -ours to keep the version of myscript.py that resides in the feature branch, and disregard the version from master. Use -ours keep the version in the current branch This is where git checkout -ours/-theirs comes into play. But in some cases, you'll want to completely disregard one version and keep the other. In most cases, you'd want to open myscript.py and sort out the merge conflicts. But when we go to merge master into feature, we're going to run into trouble: (feature) $ git merge masterĬONFLICT (content): Merge conflict in myscript.pyĪutomatic merge failed fix conflicts and then commit the result. A common strategy is to routinely merge changes from master into your feature branch during development to keep the feature branch from getting too far out of date. So changes were made to myscript.py in both master and feature branches.

The letters signify a commit, and each commit includes changes to our file: myscript.py. Imagine our git history looks like this: A-B-C feature You might be wondering about rebases, and I'll explain that in the next step.įor simplicity, let's start with a basic merge conflict. Technically speaking, use of git checkout -ours/-theirs is only applicable during a merge.
