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.

Preview
Close

Transcript from the "Reuse Recorded Resolutions" Lesson

[00:00:00]
>> 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.

[00:00:21]
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.

[00:00:40]
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.

[00:00:57]
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.

[00:01:21]
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.

[00:01:40]
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.

[00:01:58]
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.

[00:02:14]
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.

[00:02:31]
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.

[00:02:48]
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.

[00:02:58]
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 upstream.md. 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.

[00:03:20]
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.

[00:03:44]
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