feat: add autolink headings. 617a46c1a5

This commit is contained in:
jaywcjlove
2022-09-30 15:18:53 +00:00
parent 98f8b9cdb7
commit a108b1e838
24 changed files with 690 additions and 683 deletions

View File

@ -15,10 +15,10 @@
<path d="M15.06 19.39c-.62.42-1.4.77-2.35 1.08l-1.58.52c-3.97 1.28-6.06.21-7.35-3.76L2.5 13.28c-1.28-3.97-.22-6.07 3.75-7.35l1.58-.52c.41-.13.8-.24 1.17-.31-.3.61-.54 1.35-.74 2.2l-.98 4.19c-.98 4.18.31 6.24 4.48 7.23l1.68.4c.58.14 1.12.23 1.62.27Zm2.43-8.88c-.06 0-.12-.01-.19-.02l-4.85-1.23a.75.75 0 0 1 .37-1.45l4.85 1.23a.748.748 0 0 1-.18 1.47Z" fill="currentColor"></path>
<path d="M14.56 13.89c-.06 0-.12-.01-.19-.02l-2.91-.74a.75.75 0 0 1 .37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z" fill="currentColor"></path>
</svg>
<span class="title">Quick Reference</span></a><div class="menu"><a href="https://github.com/jaywcjlove/reference/blob/main/docs/git.md" class="" target="__blank"><svg viewBox="0 0 36 36" fill="currentColor" height="1em" width="1em"><path d="m33 6.4-3.7-3.7a1.71 1.71 0 0 0-2.36 0L23.65 6H6a2 2 0 0 0-2 2v22a2 2 0 0 0 2 2h22a2 2 0 0 0 2-2V11.76l3-3a1.67 1.67 0 0 0 0-2.36ZM18.83 20.13l-4.19.93 1-4.15 9.55-9.57 3.23 3.23ZM29.5 9.43 26.27 6.2l1.85-1.85 3.23 3.23Z"></path><path fill="none" d="M0 0h36v36H0z"></path></svg><span>编辑</span></a><a href="https://github.com/jaywcjlove/reference" class="" target="__blank"><svg viewBox="0 0 16 16" fill="currentColor" height="1em" width="1em"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg></a></div></div></nav><div class="wrap max-container"><header class="wrap-header h1wrap"><h1>Git 备忘清单</h1><div class="wrap-body">
<span class="title">Quick Reference</span></a><div class="menu"><a href="https://github.com/jaywcjlove/reference/blob/main/docs/git.md" class="" target="__blank"><svg viewBox="0 0 36 36" fill="currentColor" height="1em" width="1em"><path d="m33 6.4-3.7-3.7a1.71 1.71 0 0 0-2.36 0L23.65 6H6a2 2 0 0 0-2 2v22a2 2 0 0 0 2 2h22a2 2 0 0 0 2-2V11.76l3-3a1.67 1.67 0 0 0 0-2.36ZM18.83 20.13l-4.19.93 1-4.15 9.55-9.57 3.23 3.23ZM29.5 9.43 26.27 6.2l1.85-1.85 3.23 3.23Z"></path><path fill="none" d="M0 0h36v36H0z"></path></svg><span>编辑</span></a><a href="https://github.com/jaywcjlove/reference" class="" target="__blank"><svg viewBox="0 0 16 16" fill="currentColor" height="1em" width="1em"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg></a></div></div></nav><div class="wrap max-container"><header class="wrap-header h1wrap"><h1 id="git-备忘清单"><a aria-hidden="true" tabindex="-1" href="#git-备忘清单"><span class="icon icon-link"></span></a>Git 备忘清单</h1><div class="wrap-body">
<p>本备忘单总结了常用的 Git 命令行指令,以供快速参考。</p>
</div></header><div class="h1wrap-body"><div class="wrap"><div class="wrap-header h2wrap"><h2>入门</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap"><div class="wrap-header h3wrap"><h3>创建存储库</h3><div class="wrap-body">
</div></header><div class="h1wrap-body"><div class="wrap"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap"><div class="wrap-header h3wrap"><h3 id="创建存储库"><a aria-hidden="true" tabindex="-1" href="#创建存储库"><span class="icon icon-link"></span></a>创建存储库</h3><div class="wrap-body">
<p>创建一个新的本地存储库</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> init <span class="token punctuation">[</span>project name<span class="token punctuation">]</span>
</span></code></pre>
@ -28,7 +28,7 @@
<p>将存储库克隆到指定目录</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> clone git_url 指定目录
</span></code></pre>
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3>做出改变</h3><div class="wrap-body"><!--rehype:wrap-class=row-span-2-->
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3 id="做出改变"><a aria-hidden="true" tabindex="-1" href="#做出改变"><span class="icon icon-link"></span></a>做出改变</h3><div class="wrap-body"><!--rehype:wrap-class=row-span-2-->
<p>在工作目录中<strong>显示</strong>修改后的文件,为您的下一次提交暂存</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> status
</span></code></pre>
@ -59,7 +59,7 @@
<p>在指定分支之前应用当前分支的任何提交</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> rebase <span class="token punctuation">[</span>branch<span class="token punctuation">]</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>配置</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="配置"><a aria-hidden="true" tabindex="-1" href="#配置"><span class="icon icon-link"></span></a>配置</h3><div class="wrap-body">
<p>设置将附加到您的提交和标签的名称</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> config <span class="token parameter variable">--global</span> user.name <span class="token string">"name"</span>
</span></code></pre>
@ -72,7 +72,7 @@
<p>在文本编辑器中编辑全局配置文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> config <span class="token parameter variable">--global</span> <span class="token parameter variable">--edit</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>使用分支</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="使用分支"><a aria-hidden="true" tabindex="-1" href="#使用分支"><span class="icon icon-link"></span></a>使用分支</h3><div class="wrap-body">
<p>列出所有本地分支</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> branch
</span></code></pre>
@ -95,7 +95,7 @@
<p>标记当前提交</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> tag my_tag
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>观察你的存储库</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="观察你的存储库"><a aria-hidden="true" tabindex="-1" href="#观察你的存储库"><span class="icon icon-link"></span></a>观察你的存储库</h3><div class="wrap-body">
<p>显示当前活动分支的提交历史</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> log
</span></code></pre>
@ -111,7 +111,7 @@
<p>以人类可读的格式显示 Git 中的任何对象</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> show <span class="token punctuation">[</span>SHA<span class="token punctuation">]</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>同步</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="同步"><a aria-hidden="true" tabindex="-1" href="#同步"><span class="icon icon-link"></span></a>同步</h3><div class="wrap-body">
<p>从该 Git 远程获取所有分支</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> fetch <span class="token punctuation">[</span>alias<span class="token punctuation">]</span>
</span></code></pre>
@ -131,7 +131,7 @@
<p>将另一个分支的一个特定提交合并到当前分支</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> cherry-pick <span class="token punctuation">[</span>commit_id<span class="token punctuation">]</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>远程</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="远程"><a aria-hidden="true" tabindex="-1" href="#远程"><span class="icon icon-link"></span></a>远程</h3><div class="wrap-body">
<p>添加一个 git URL 作为别名</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> remote <span class="token function">add</span> <span class="token punctuation">[</span>alias<span class="token punctuation">]</span> <span class="token punctuation">[</span>url<span class="token punctuation">]</span>
</span></code></pre>
@ -147,7 +147,7 @@
<p>更改 git repo 的 URL</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> remote set-url origin <span class="token punctuation">[</span>git_url<span class="token punctuation">]</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>临时提交</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="临时提交"><a aria-hidden="true" tabindex="-1" href="#临时提交"><span class="icon icon-link"></span></a>临时提交</h3><div class="wrap-body">
<p>保存已修改和分阶段的更改</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> stash
</span></code></pre>
@ -160,7 +160,7 @@
<p>丢弃存储堆栈顶部的更改</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> stash drop
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>跟踪路径更改</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="跟踪路径更改"><a aria-hidden="true" tabindex="-1" href="#跟踪路径更改"><span class="icon icon-link"></span></a>跟踪路径更改</h3><div class="wrap-body">
<p>从项目中删除文件并暂存删除以进行提交</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> <span class="token function">rm</span> <span class="token punctuation">[</span>file<span class="token punctuation">]</span>
</span></code></pre>
@ -170,7 +170,7 @@
<p>显示所有提交日志,并指示任何移动的路径</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> log <span class="token parameter variable">--stat</span> <span class="token parameter variable">-M</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>忽略文件</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="忽略文件"><a aria-hidden="true" tabindex="-1" href="#忽略文件"><span class="icon icon-link"></span></a>忽略文件</h3><div class="wrap-body">
<pre class="language-gitignore"><code class="language-gitignore code-highlight"><span class="code-line line-number" line="1"><span class="token entry string"><span class="token punctuation">/</span>logs<span class="token punctuation">/</span><span class="token operator">*</span></span>
</span><span class="code-line line-number" line="2"><span class="token comment"># “!” 意思是不要忽视</span>
</span><span class="code-line line-number" line="3"><span class="token entry string"><span class="token operator">!</span>logs<span class="token punctuation">/</span>.gitkeep</span>
@ -182,20 +182,20 @@
</span><span class="code-line line-number" line="9"><span class="token entry string">.sass-cache</span>
</span></code></pre>
<p><code>.gitignore</code> 文件指定了 Git 应该忽略的未跟踪的文件</p>
</div></div></div></div></div><div class="wrap"><div class="wrap-header h2wrap"><h2>Git 技巧</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap"><div class="wrap-header h3wrap"><h3>重命名分支</h3><div class="wrap-body">
</div></div><div class="h3wrap-body"><div class="wrap"><div class="wrap-header h4wrap"><h4><strong>重命名</strong><code>new</code></h4><div class="wrap-body">
</div></div></div></div></div><div class="wrap"><div class="wrap-header h2wrap"><h2 id="git-技巧"><a aria-hidden="true" tabindex="-1" href="#git-技巧"><span class="icon icon-link"></span></a>Git 技巧</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap"><div class="wrap-header h3wrap"><h3 id="重命名分支"><a aria-hidden="true" tabindex="-1" href="#重命名分支"><span class="icon icon-link"></span></a>重命名分支</h3><div class="wrap-body">
</div></div><div class="h3wrap-body"><div class="wrap"><div class="wrap-header h4wrap"><h4 id="重命名为new"><a aria-hidden="true" tabindex="-1" href="#重命名为new"><span class="icon icon-link"></span></a><strong>重命名</strong><code>new</code></h4><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> branch <span class="token parameter variable">-m</span> <span class="token operator">&#x3C;</span>new<span class="token operator">></span>
</span><span class="code-line line-number" line="2">$ <span class="token function">git</span> branch <span class="token parameter variable">-m</span> <span class="token operator">&#x3C;</span>old<span class="token operator">></span> <span class="token operator">&#x3C;</span>new<span class="token operator">></span> <span class="token comment"># 重命名分支 </span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h4wrap"><h4><strong>推送</strong>并重置</h4><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h4wrap"><h4 id="推送并重置"><a aria-hidden="true" tabindex="-1" href="#推送并重置"><span class="icon icon-link"></span></a><strong>推送</strong>并重置</h4><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> push origin <span class="token parameter variable">-u</span> <span class="token operator">&#x3C;</span>new<span class="token operator">></span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h4wrap"><h4><strong>删除</strong>远程分支</h4><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h4wrap"><h4 id="删除远程分支"><a aria-hidden="true" tabindex="-1" href="#删除远程分支"><span class="icon icon-link"></span></a><strong>删除</strong>远程分支</h4><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> push origin <span class="token parameter variable">--delete</span> <span class="token operator">&#x3C;</span>old<span class="token operator">></span> <span class="token comment"># 方法1</span>
</span><span class="code-line line-number" line="2">$ <span class="token function">git</span> push origin :oldBranchName <span class="token comment"># 方法2</span>
</span></code></pre>
</div></div></div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>Log</h3><div class="wrap-body">
</div></div></div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="log"><a aria-hidden="true" tabindex="-1" href="#log"><span class="icon icon-link"></span></a>Log</h3><div class="wrap-body">
<p>按内容搜索更改</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> log -S<span class="token string">'&#x3C;a term in the source>'</span>
</span></code></pre>
@ -205,7 +205,7 @@
<p>打印出很酷的日志可视化</p>
<pre class="wrap-text"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> log <span class="token parameter variable">--pretty</span><span class="token operator">=</span>oneline <span class="token parameter variable">--graph</span> <span class="token parameter variable">--decorate</span> <span class="token parameter variable">--all</span>
</span></code></pre><!--rehype:className=wrap-text-->
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3>分支</h3><div class="wrap-body"><!--rehype:wrap-class=row-span-2-->
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3 id="分支"><a aria-hidden="true" tabindex="-1" href="#分支"><span class="icon icon-link"></span></a>分支</h3><div class="wrap-body"><!--rehype:wrap-class=row-span-2-->
<p>列出所有分支及其上游</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> branch <span class="token parameter variable">-vv</span>
</span></code></pre>
@ -221,22 +221,22 @@
<p>删除本地存在远程不存在的分支</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> remote prune origin
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>Commit</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="commit"><a aria-hidden="true" tabindex="-1" href="#commit"><span class="icon icon-link"></span></a>Commit</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> commit <span class="token parameter variable">-v</span> <span class="token parameter variable">--amend</span>
</span></code></pre>
<p>重写最后的提交信息</p>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>忽略文件的权限变化</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="忽略文件的权限变化"><a aria-hidden="true" tabindex="-1" href="#忽略文件的权限变化"><span class="icon icon-link"></span></a>忽略文件的权限变化</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> config core.fileMode <span class="token boolean">false</span>
</span></code></pre>
<p>不再将文件的权限变化视作改动</p>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>Git 别名</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="git-别名"><a aria-hidden="true" tabindex="-1" href="#git-别名"><span class="icon icon-link"></span></a>Git 别名</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> config <span class="token parameter variable">--global</span> alias.co checkout
</span><span class="code-line line-number" line="2">$ <span class="token function">git</span> config <span class="token parameter variable">--global</span> alias.br branch
</span><span class="code-line line-number" line="3">$ <span class="token function">git</span> config <span class="token parameter variable">--global</span> alias.ci commit
</span><span class="code-line line-number" line="4">$ <span class="token function">git</span> config <span class="token parameter variable">--global</span> alias.st status
</span></code></pre>
<p>也可以看看:<a href="https://gist.github.com/johnpolacek/69604a1f6861129ef088">More Aliases</a></p>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>设置大小写敏感</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="设置大小写敏感"><a aria-hidden="true" tabindex="-1" href="#设置大小写敏感"><span class="icon icon-link"></span></a>设置大小写敏感</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 查看git 的设置</span>
</span><span class="code-line line-number" line="2">$ <span class="token function">git</span> config <span class="token parameter variable">--get</span> core.ignorecase
</span><span class="code-line line-number" line="3"><span class="token comment"># 设置大小写敏感</span>
@ -244,7 +244,7 @@
</span><span class="code-line line-number" line="5"><span class="token comment"># 远程有俩相同目录,通过这种方式清除掉,然后提交记录</span>
</span><span class="code-line line-number" line="6">$ <span class="token function">git</span> <span class="token function">rm</span> <span class="token parameter variable">-r</span> <span class="token parameter variable">--cached</span> <span class="token operator">&#x3C;</span>目录/文件<span class="token operator">></span>
</span></code></pre>
</div></div></div><div class="wrap row-span-4"><div class="wrap-header h3wrap"><h3>修改远程 Commit 记录</h3><div class="wrap-body"><!--rehype:wrap-class=row-span-4-->
</div></div></div><div class="wrap row-span-4"><div class="wrap-header h3wrap"><h3 id="修改远程-commit-记录"><a aria-hidden="true" tabindex="-1" href="#修改远程-commit-记录"><span class="icon icon-link"></span></a>修改远程 Commit 记录</h3><div class="wrap-body"><!--rehype:wrap-class=row-span-4-->
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> rebase <span class="token parameter variable">-i</span> HEAD~3
</span><span class="code-line line-number" line="2"><span class="token comment"># 表示要修改当前版本的倒数第三次状态</span>
</span><span class="code-line line-number" line="3"><span class="token comment"># 将要更改的记录行首单词 pick 改为 edit</span>
@ -281,13 +281,13 @@
</span><span class="code-line line-number" line="15"><span class="token comment"># 最后,确保没有人提交进行推送,最好不要加 -f 强制推送</span>
</span><span class="code-line line-number" line="16">$ <span class="token function">git</span> push <span class="token parameter variable">-f</span> origin master
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>撤销远程记录</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="撤销远程记录"><a aria-hidden="true" tabindex="-1" href="#撤销远程记录"><span class="icon icon-link"></span></a>撤销远程记录</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 撤销一条记录 </span>
</span><span class="code-line line-number" line="2">$ <span class="token function">git</span> reset <span class="token parameter variable">--hard</span> HEAD~1
</span><span class="code-line line-number" line="3"><span class="token comment"># 强制同步到远程仓库 </span>
</span><span class="code-line line-number" line="4">$ <span class="token function">git</span> push <span class="token parameter variable">-f</span> origin HEAD:master
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>放弃本地修改内容</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="放弃本地修改内容"><a aria-hidden="true" tabindex="-1" href="#放弃本地修改内容"><span class="icon icon-link"></span></a>放弃本地修改内容</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 如果有的修改以及加入暂存区的话</span>
</span><span class="code-line line-number" line="2">$ <span class="token function">git</span> reset <span class="token parameter variable">--hard</span>
</span><span class="code-line line-number" line="3"><span class="token comment"># 还原所有修改,不会删除新增的文件</span>
@ -295,18 +295,18 @@
</span><span class="code-line line-number" line="5"><span class="token comment"># 下面命令会删除新增的文件</span>
</span><span class="code-line line-number" line="6">$ <span class="token function">git</span> clean <span class="token parameter variable">-xdf</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>获取最近一次提交的 Hash</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="获取最近一次提交的-hash"><a aria-hidden="true" tabindex="-1" href="#获取最近一次提交的-hash"><span class="icon icon-link"></span></a>获取最近一次提交的 Hash</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> rev-parse HEAD <span class="token comment"># e10721cb8859b2c</span>
</span><span class="code-line line-number" line="2"><span class="token comment"># 获取短 hash</span>
</span><span class="code-line line-number" line="3">$ <span class="token function">git</span> rev-parse <span class="token parameter variable">--short</span> HEAD <span class="token comment"># e10721c</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>删除已经合并到 master 的分支</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="删除已经合并到-master-的分支"><a aria-hidden="true" tabindex="-1" href="#删除已经合并到-master-的分支"><span class="icon icon-link"></span></a>删除已经合并到 master 的分支</h3><div class="wrap-body">
<pre class="wrap-text"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> branch <span class="token parameter variable">--merged</span> master <span class="token operator">|</span> <span class="token function">grep</span> <span class="token parameter variable">-v</span> <span class="token string">'^\*\| master'</span> <span class="token operator">|</span> <span class="token function">xargs</span> <span class="token parameter variable">-n</span> <span class="token number">1</span> <span class="token function">git</span> branch <span class="token parameter variable">-d</span>
</span></code></pre><!--rehype:className=wrap-text-->
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>中文乱码的解决方案</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="中文乱码的解决方案"><a aria-hidden="true" tabindex="-1" href="#中文乱码的解决方案"><span class="icon icon-link"></span></a>中文乱码的解决方案</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> config <span class="token parameter variable">--global</span> core.quotepath <span class="token boolean">false</span>
</span></code></pre>
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3>把 A 分支的某一个 commit放到 B 分支上</h3><div class="wrap-body">
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="把-a-分支的某一个-commit放到-b-分支上"><a aria-hidden="true" tabindex="-1" href="#把-a-分支的某一个-commit放到-b-分支上"><span class="icon icon-link"></span></a>把 A 分支的某一个 commit放到 B 分支上</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 切换到 B 分支</span>
</span><span class="code-line line-number" line="2">$ <span class="token function">git</span> checkout <span class="token operator">&#x3C;</span>B<span class="token operator">></span>
</span><span class="code-line line-number" line="3"><span class="token comment"># 将 A 分支 &#x3C;hash-id> 的内容 pick 到 B 分支</span>