Check out a free preview of the full Everything You'll Need to Know About Git course

The "Reuse Recorded Resolutions" Lesson is part of the full, Everything You'll Need to Know About Git course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen discusses the use of the "rerere" option in Git to resolve conflicts more easily and explains how to enable "rerere" locally or globally. He also explains that, with "rerere" enabled, git will automatically remember how a conflict was previously handled and replay the decision the next time the conflict occurs.


Transcript from the "Reuse Recorded Resolutions" Lesson

>> All right, so we have an act of conflict right now and we need to resolve it. So given what you know, even though I've already foreshadowed and already told you, would you use rebase if this was the experience of rebase? My guess is most people probably really wouldn't wanna necessarily use rebase if it means you're gonna conflict for any long-held branch Over and over again.

That'd be a pretty bad experience, just in general. So hey, that probably helped me not have long running feature branches. So it's like a cure through pain and misery. So it's a really nice way to kind of fix that problem, but here we are. So anyways, I wouldn't personally wanna use it just because it's just people Be a pain.

So instead, there's likely something you don't know about, it's called rerere. It's one of the strange options and all of git stands for recorded reuse, recorded resolutions. Even from the Git docs, it says this functionality is a bit of a hidden feature. It's like the best feature and it's hidden.

Why would you do this? Why would you name this? Why is it like this? Just so painful that this why are you the way you are, right? That's the meme, right? It's happening right before our eyes and so all you have to do is enable rerer. You can enable it in your config which means we can enable it locally just for this repo or you can enable it globally for All of your repos.

So for the sake of you not having your system altered in any sort of way, just enable it locally for justice rebound. So I'm gonna go get config and rerere enabled the enabled, right? Yeah with the enabled true. There we go. We just did we enabled it. It's been.

Fantastic, right? And right now we're still we're still conflicting. Remember that we're still in the middle of this. It's terrible. Let's see where we're at. Okay, good. Everything we have the change in there, so I'll just add it. We'll do a git rebase continue. It will play it oopsies all right, spelt continue wrong.

Will now edit our commit message. I'll keep the Commit message the same because again, remember rebase gives you the chance to edit your commit message. I don't want to edit it. Awesome. We resolved the conflict. Now, let's see something here. Okay, fantastic, we did this. By the way, it's on our local list.

So if you do that, if you go git config, I forgot to say this, list. Local only, so these are only local options. You'll see re, re, re is right here. All right, you can cat out the git config. You see it right there. So, okay, awesome. It's been enabled.

We're ready. Fantastic. And we already talked about what it is. It's not all sunshine and rainbows, by the way. Sometimes you could resolve something Thing in a way you don't like and you need to be able to go through and you can actually delete how you have recorded your resolutions so they don't replay again.

So that can kind of be a pain when you're like, that was a bad merge. And then you try to pull again and it just automatically does it for you. And you're like, dangit, it just knew what it was doing, right? And you don't want that to happen, but it did.

So just remember that. All right So let's resolve our conflict and accept our change with A plus 6. So let's go back to Hello Git, and let's make a simple change to just Now, if we didn't have recorded resolutions on, we would actually conflict again here. But instead, if I go upstream, go right here, and go another change with a re-re-re.

We'll go like that. We'll git add, we'll get commit rerere, right. And now I can git pull rebase on remote and it's just gonna successfully rebase for us. Everything's great. We're not, we're re conflicting. It's just smooth sailing now. So. Very nice to have rerere on, I would highly recommend having it on.

Just that only one thing you got to be careful about is of course the bad resolution. All right rerere is free. You can just use it for free. Nothing

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now