WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Git · Expert · question 70 of 100

How do you use ’git rerere’ to handle repeated merge conflicts in long-lived branches?

📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

git rerere is a Git command that stands for "reuse recorded resolution". It allows Git to remember how merge conflicts were resolved in the past and apply those resolutions automatically in the future when it encounters similar conflicts.

When two or more branches are merged in Git, conflicts can arise when the same code has been modified in different ways in each branch. Resolving these conflicts can be time-consuming and error-prone, especially when dealing with long-lived branches that are frequently merged.

To use git rerere, you first need to enable it by running the command:

    $ git config --global rerere.enabled true

Once enabled, git rerere will automatically start recording conflict resolutions when you resolve merge conflicts manually. You can then use the recorded resolutions to automatically resolve conflicts in the future by running the command:

    $ git rerere

This command will scan the current repository for recorded resolutions and apply them to any conflicts it encounters.

You can also use the git rerere command to manually resolve merge conflicts using previously recorded resolutions. For example, to resolve a conflict using a previously recorded resolution, you can run:

    $ git rerere
    $ git add <conflicted-file>
    $ git commit

The git rerere command can save a significant amount of time and effort when dealing with repeated merge conflicts. However, it’s important to note that it can also introduce risks if not used carefully. In particular, it’s possible for git rerere to apply incorrect resolutions to conflicts, leading to incorrect code changes. Therefore, it’s important to review the changes introduced by git rerere carefully and test them thoroughly before committing them to the repository.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Git interview — then scores it.
📞 Practice Git — free 15 min
📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

All 100 Git questions · All topics