<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Socket on LeafCxy's Blog</title><link>https://leafcxy.github.io/tags/socket/</link><description>Recent content in Socket on LeafCxy's Blog</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Mon, 18 Aug 2025 02:28:16 +0000</lastBuildDate><atom:link href="https://leafcxy.github.io/tags/socket/index.xml" rel="self" type="application/rss+xml"/><item><title>Git的奇技淫巧</title><link>https://leafcxy.github.io/posts/2025-08-18/</link><pubDate>Mon, 18 Aug 2025 02:28:16 +0000</pubDate><guid>https://leafcxy.github.io/posts/2025-08-18/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Git 常用命令集合，Fork 自 &lt;a href="https://github.com/git-tips/tips"&gt;tips&lt;/a&gt; 项目&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Git 是一个分布式版本管理工具，版本管理工具就是大家在写东西的时候都用过 &lt;strong&gt;回撤&lt;/strong&gt;这个功能，但是回撤只能回撤几步，假如想要找回我三天之前的修改，光用回撤是找不回来的。而&lt;strong&gt;版本管理工具能记录每次的修改&lt;/strong&gt;，只要提交到版本仓库，就可以找到之前任何时刻的状态（文本状态）。&lt;/p&gt;
&lt;p&gt;下面的内容就是列举了常用的 Git 命令和一些小技巧，可以通过页面内查找的方式 &lt;code&gt;Ctrl/Command+f&lt;/code&gt; 进行快速查找。&lt;/p&gt;
&lt;!-- more --&gt;
&lt;h2 id="开卷必读"&gt;开卷必读&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;如果之前未使用过 Git，可以学习 &lt;a href="https://rogerdudler.github.io/git-guide/index.zh.html"&gt;Git 小白教程&lt;/a&gt;入门&lt;/em&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;一定要先测试命令的效果后&lt;/strong&gt;，再用于工作环境中，以防造成不能弥补的后果！&lt;strong&gt;到时候别拿着砍刀来找我&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;所有的命令都在 &lt;code&gt;git version 2.7.4 (Apple Git-66)&lt;/code&gt; 下测试通过&lt;/li&gt;
&lt;li&gt;统一概念：
&lt;ul&gt;
&lt;li&gt;工作区：改动（增删文件和内容）&lt;/li&gt;
&lt;li&gt;暂存区：输入命令：&lt;code&gt;git add 改动的文件名&lt;/code&gt;，此次改动就放到了 ‘暂存区’&lt;/li&gt;
&lt;li&gt;本地仓库(简称：本地)：输入命令：&lt;code&gt;git commit 此次修改的描述&lt;/code&gt;，此次改动就放到了本地仓库，每个 commit，我叫它为一个版本。&lt;/li&gt;
&lt;li&gt;远程仓库(简称：远程)：输入命令：&lt;code&gt;git push 远程仓库&lt;/code&gt;，此次改动就放到了远程仓库（GitHub 等)&lt;/li&gt;
&lt;li&gt;commit-id：输出命令：&lt;code&gt;git log&lt;/code&gt;，最上面那行 &lt;code&gt;commit xxxxxx&lt;/code&gt;，后面的字符串就是 commit-id&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;如果喜欢这个项目，欢迎 Star、提交 Pr、&lt;a href="https://github.com/521xueweihan/git-tips/issues"&gt;反馈问题&lt;/a&gt;😊&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="展示帮助信息"&gt;展示帮助信息&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git help -g
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The command output as below:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;The common Git guides are:
attributes Defining attributes per path
cli Git command-line interface and conventions
core-tutorial A Git core tutorial for developers
cvs-migration Git for CVS users
diffcore Tweaking diff output
everyday A useful minimum set of commands for Everyday Git
glossary A Git Glossary
hooks Hooks used by Git
ignore Specifies intentionally untracked files to ignore
modules Defining submodule properties
namespaces Git namespaces
repository-layout Git Repository Layout
revisions Specifying revisions and ranges for Git
tutorial A tutorial introduction to Git
tutorial-2 A tutorial introduction to Git: part two
workflows An overview of recommended workflows with Git
&amp;#39;git help -a&amp;#39; and &amp;#39;git help -g&amp;#39; list available subcommands and some concept guides. See &amp;#39;git help &amp;lt;command&amp;gt;&amp;#39; or &amp;#39;git help &amp;lt;concept&amp;gt;&amp;#39; to read about a specific subcommand or concept.
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="回到远程仓库的状态"&gt;回到远程仓库的状态&lt;/h2&gt;
&lt;p&gt;抛弃本地所有的修改，回到远程仓库的状态。&lt;/p&gt;</description></item></channel></rss>