2024-09-24 08:56:37 +00:00
|
|
|
|
import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js";
|
2024-05-30 02:02:10 +00:00
|
|
|
|
const __pageData = JSON.parse('{"title":"Resolving Merge Conflicts","description":"","frontmatter":{},"headers":[],"relativePath":"newbs_git_resolving_merge_conflicts.md","filePath":"newbs_git_resolving_merge_conflicts.md"}');
|
|
|
|
|
const _sfc_main = { name: "newbs_git_resolving_merge_conflicts.md" };
|
|
|
|
|
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="resolving-merge-conflicts" tabindex="-1">Resolving Merge Conflicts <a class="header-anchor" href="#resolving-merge-conflicts" aria-label="Permalink to "Resolving Merge Conflicts""></a></h1><p>Sometimes when your work in a branch takes a long time to complete, changes that have been made by others conflict with changes you have made to your branch when you open a pull request. This is called a <em>merge conflict</em>, and is what happens when multiple people edit the same parts of the same files.</p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>This document builds upon the concepts detailed in <a href="./newbs_git_using_your_master_branch">Your Fork's Master: Update Often, Commit Never</a>. If you are not familiar with that document, please read it first, then return here.</p></div><h2 id="rebasing-your-changes" tabindex="-1">Rebasing Your Changes <a class="header-anchor" href="#rebasing-your-changes" aria-label="Permalink to "Rebasing Your Changes""></a></h2><p>A <em>rebase</em> is Git's way of taking changes that were applied at one point in the commit history, reversing them, and then applying the same changes at another point. In the case of a merge conflict, you can rebase your branch to grab the changes that were made between when you created your branch and the present time.</p><p>To start, run the following:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span>git fetch upstream</span></span>\n<span class="line"><span>git rev-list --left-right --count HEAD...upstream/master</span></span></code></pre></div><p>The <code>git rev-list</code> command entered here returns the number of commits that differ between the current branch and QMK's master branch. We run <code>git fetch</code> first to make sure we have the refs that represent the current state of the upstream repo. The output of the <code>git rev-list</code> command entered returns two numbers:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span>$ git rev-list --left-right --count HEAD...upstream/master</span></span>\n<span class="line"><span>7 35</span></span></code></pre></div><p>The first number represents the number of commits on the current branch since it was created, and the second number is the number of commits made to <code>upstream/master</code> since the current branch was created, and thus, the changes that are not recorded in the current branch.</p><p>Now that the current states of both the current branch and the upstream repo are known, we can start a rebase operation:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span>git rebase upstream/master</span></span></code></pre></div><p>This tells Git to undo the commits on the current branch, and then reapply them against QMK's master branch.</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span>$ git rebase upstream/master</span></span>\n<span class="line"><span>First, rewinding head to replay your work on top of it...</span></span>\n<span class="line"><span>Applying: Commit #1</span></span>\n<span class="line"><span>Using index info to reconstruct a base tree...</span></span>\n<span class="line"><span>M conflicting_file_1.txt</span></span>\n<span class="line"><span>Falling back to patching base and 3-way merge...</span></span>\n<span class="line"><span>Auto-merging conflicting_file_1.txt</span></span>\n<span class="line"><span
|
|
|
|
|
const _hoisted_23 = [
|
|
|
|
|
_hoisted_1
|
|
|
|
|
];
|
|
|
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
|
|
return openBlock(), createElementBlock("div", null, _hoisted_23);
|
|
|
|
|
}
|
|
|
|
|
const newbs_git_resolving_merge_conflicts = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
|
|
|
export {
|
|
|
|
|
__pageData,
|
|
|
|
|
newbs_git_resolving_merge_conflicts as default
|
|
|
|
|
};
|