qmk_firmware/assets/newbs_git_resynchronize_a_branch.md.Bs5OHG0T.js

16 lines
7.1 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js";
const __pageData = JSON.parse('{"title":"Resynchronizing an Out-of-Sync Git Branch","description":"","frontmatter":{},"headers":[],"relativePath":"newbs_git_resynchronize_a_branch.md","filePath":"newbs_git_resynchronize_a_branch.md","lastUpdated":null}');
const _sfc_main = { name: "newbs_git_resynchronize_a_branch.md" };
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="resynchronizing-an-out-of-sync-git-branch" tabindex="-1">Resynchronizing an Out-of-Sync Git Branch <a class="header-anchor" href="#resynchronizing-an-out-of-sync-git-branch" aria-label="Permalink to &quot;Resynchronizing an Out-of-Sync Git Branch&quot;"></a></h1><p>Suppose you have committed to your <code>master</code> branch, and now need to update your QMK repository. You could <code>git pull</code> QMK&#39;s <code>master</code> branch into your own, but GitHub will tell you that your branch is a number of commits ahead of <code>qmk:master</code>, which can create issues if you want to make a pull request to QMK.</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&#39;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="backing-up-the-changes-on-your-own-master-branch-optional" tabindex="-1">Backing Up the Changes on Your Own Master Branch (Optional) <a class="header-anchor" href="#backing-up-the-changes-on-your-own-master-branch-optional" aria-label="Permalink to &quot;Backing Up the Changes on Your Own Master Branch (Optional)&quot;"></a></h2><p>No one wants to lose work if it can be helped. If you want to save the changes you&#39;ve already made to your <code>master</code> branch, the simplest way to do so is to simply create a duplicate of your &quot;dirty&quot; <code>master</code> 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 branch old_master master</span></span></code></pre></div><p>Now you have a branch named <code>old_master</code> that is a duplicate of your <code>master</code> branch.</p><h2 id="resynchronizing-your-branch" tabindex="-1">Resynchronizing Your Branch <a class="header-anchor" href="#resynchronizing-your-branch" aria-label="Permalink to &quot;Resynchronizing Your Branch&quot;"></a></h2><p>Now it&#39;s time to resynchronize your <code>master</code> branch. For this step, you&#39;ll want to have QMK&#39;s repository configured as a remote in Git. To check your configured remotes, run <code>git remote -v</code>, which should return something similar to:</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>QMKuser ~/qmk_firmware (master)</span></span>\n<span class="line"><span>$ git remote -v</span></span>\n<span class="line"><span>origin https://github.com/&lt;your_username&gt;/qmk_firmware.git (fetch)</span></span>\n<span class="line"><span>origin https://github.com/&lt;your_username&gt;/qmk_firmware.git (push)</span></span>\n<span class="line"><span>upstream https://github.com/qmk/qmk_firmware.git (fetch)</span></span>\n<span class="line"><span>upstream https://github.com/qmk/qmk_firmware.git (push)</span></span></code></pre></div><p>If you only see one fork referenced:</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>QMKuser ~/qmk_firmware (master)</span></span>\n<span class="line"><span>$ git remote -v</span></span>\n<span class="line"><span>origin https://github.com/qmk/qmk_firmware.git (fetch)</span></span>\n<span class="line"><span>origin https://github.com/qmk/qmk_firmware.git (push)</span></span></code></pre></div><p>add a new remote with:</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 remote add upstream https://github.com/qmk/qmk_firmware.git</span></span></code></pre></div><p>Then, redirect the <code>origin</code> remote to your own fork with:</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 remote set-url origin https://github.com/&lt;your_username&gt;/qmk_firmware.git</span></span></code></pre></div><p>Now that you have both remotes configured, you need to update the references for the upstream repository, which is QMK&#39;s, by running:</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 --recurse-submodules upstream</span></span></code></pre></div><p>At this point, resynchronize your branch to QMK&#39;s by running:</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 reset --recurse-submodules --hard upstream/master</span></span></code></pre></div><p>These steps will update the repository on your computer, but your GitHub fork will still be out of sync. To resynchronize your fork on GitHub, you need to push to your fork, instructing Git to override any remote changes that are not reflected in your local repository. To do this, run:</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 push --recurse-submodules=on-demand --force-with-lease</span></span></code></pre></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p><strong>DO NOT</strong> run <code>git push --recurse-submodules=on-demand --force-with-lease</code> on a fork to which other users post commits. This will erase their commits.</p></div><p>Now your GitHub fork, your local files, and QMK&#39;s repository are all the same. From here you can make further needed changes (<a href="./newbs_git_using_your_master_branch#making-changes">use a branch!</a>) and post them as normal.</p>', 24);
const _hoisted_25 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, _hoisted_25);
}
const newbs_git_resynchronize_a_branch = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
__pageData,
newbs_git_resynchronize_a_branch as default
};