{"id":274,"date":"2023-11-24T15:35:00","date_gmt":"2023-11-24T07:35:00","guid":{"rendered":"https:\/\/solost.cn\/?p=274"},"modified":"2023-11-25T02:06:41","modified_gmt":"2023-11-24T18:06:41","slug":"405","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=274","title":{"rendered":"Git\u57fa\u672c\u64cd\u4f5c"},"content":{"rendered":"<h2>\u521d\u59cb\u5316\u8bbe\u7f6e<\/h2>\n<h3>\u914d\u7f6e\u7528\u6237\u540d<\/h3>\n<pre><code>git config --global user.name &quot;Your Name&quot;<\/code><\/pre>\n<h3>\u914d\u7f6e\u90ae\u7bb1<\/h3>\n<pre><code>git config --global user.email &quot;mail@example.com&quot;<\/code><\/pre>\n<h3>\u5b58\u50a8\u914d\u7f6e<\/h3>\n<pre><code>git config --global credential store<\/code><\/pre>\n<h2>\u65b0\u5efa\u4ed3\u5e93<\/h2>\n<h3>\u521b\u5efa\u2f00\u4e2a\u65b0\u7684\u672c\u5730\u4ed3\u5e93\uff08\u7701\u7565project-name \u5219\u5728\u5f53\u524d\u76ee\u5f55\u521b\u5efa\uff09<\/h3>\n<pre><code>git init &lt;project-name&gt;<\/code><\/pre>\n<h3>\u514b\u9686\u2f00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<pre><code>git clone &lt;url&gt;<\/code><\/pre>\n<h2>\u5de5\u4f5c\u533a\u57df<\/h2>\n<h3>\u5de5\u4f5c\u533a\uff08Working Directory\uff09<\/h3>\n<p>\u5c31\u662f\u4f60\u5728\u7535\u8111\u2fa5\u80fd\u5b9e\u9645\u770b\u5230\u7684\u2f6c\u5f55<\/p>\n<h3>\u6682\u5b58\u533a\uff08Stage\/Index\uff09<\/h3>\n<p>\u6682\u5b58\u533a\u4e5f\u53eb\u7d22\u5f15\uff0c\u2f64\u6765\u4e34\u65f6\u5b58\u653e\u672a\u63d0\u4ea4\u7684\u5185\u5bb9\uff0c\u2f00\u822c\u5728.git \u2f6c\u5f55\u4e0b\u7684index \u4e2d\u3002<\/p>\n<h3>\u672c\u5730\u4ed3\u5e93\uff08Repository\uff09<\/h3>\n<p>Git \u5728\u672c\u5730\u7684\u7248\u672c\u5e93\uff0c \u4ed3\u5e93\u4fe1\u606f\u5b58\u50a8\u5728.git \u8fd9\u4e2a\u9690\u85cf\u2f6c\u5f55\u4e2d\u3002<\/p>\n<h3>\u8fdc\u7a0b\u4ed3\u5e93\uff08Remote Repository\uff09<\/h3>\n<p>\u6258\u7ba1\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u7684\u4ed3\u5e93\u3002 \u5e38\u2f64\u7684\u6709GitHub\uff0c GitLab\uff0c Gitee\u3002<\/p>\n<h2>\u6587\u4ef6\u72b6\u6001<\/h2>\n<h3>\u5df2\u4fee\u6539\uff08Modified\uff09<\/h3>\n<p>\u4fee\u6539\u4e86\u4f46\u662f\u6ca1\u6709\u4fdd\u5b58\u5230\u6682\u5b58\u533a\u7684\u2f42\u4ef6<\/p>\n<h3>\u5df2\u6682\u5b58\uff08Staged\uff09<\/h3>\n<p>\u4fee\u6539\u540e\u5df2\u7ecf\u4fdd\u5b58\u5230\u6682\u5b58\u533a\u7684\u2f42\u4ef6<\/p>\n<h3>\u5df2\u63d0\u4ea4\uff08Committed\uff09<\/h3>\n<p>\u628a\u6682\u5b58\u533a\u7684\u2f42\u4ef6\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93\u540e\u7684\u72b6\u6001<\/p>\n<h2>\u6587\u4ef6\u540d\u79f0<\/h2>\n<pre><code>main\/master \u9ed8\u8ba4\u4e3b\u5206\u652f\nOrigin \u9ed8\u8ba4\u8fdc\u7a0b\u4ed3\u5e93\nHEAD \u6307\u5411\u5f53\u524d\u5206\u652f\u7684\u6307\u9488\nHEADA \u4e0a\u4e00\u4e2a\u7248\u672c\nHEAD~ \u4e0a\u56db\u4e2a\u7248\u672c<\/code><\/pre>\n<h2>\u6dfb\u52a0\u548c\u63d0\u4ea4\u6587\u4ef6<\/h2>\n<pre><code>git add &lt;file<\/code><\/pre>\n<p>\u6dfb\u52a0\u2f00\u4e2a\u2f42\u4ef6\u5230\u6682\u5b58\u533a\uff0c\u2f50\u5982git add . \u5c31\u8868\u793a\u6dfb\u52a0\u6240\u6709\u2f42\u4ef6\u5230\u6682\u5b58\u533a\u3002<\/p>\n<pre><code>git commit -m &quot;message&quot;<\/code><\/pre>\n<p>\u63d0\u4ea4\u6240\u6709\u6682\u5b58\u533a\u7684\u2f42\u4ef6\u5230\u672c\u5730\u4ed3\u5e93<\/p>\n<pre><code>git commit -am &quot;message&quot;<\/code><\/pre>\n<p>\u63d0\u4ea4\u6240\u6709\u5df2\u4fee\u6539\u7684\u2f42\u4ef6\u5230\u672c\u5730\u4ed3\u5e93<\/p>\n<h2>\u5220\u9664 \u64a4\u9500 \u6062\u590d<\/h2>\n<pre><code class=\"lang-bash\">git mv &lt;file&gt;&lt;new-file&gt;<\/code><\/pre>\n<p>\u79fb\u52a8\u4e00\u4e2a\u6587\u4ef6\u5230\u65b0\u7684\u4f4d\u7f6e\u3002<\/p>\n<pre><code>git rm &lt;file&gt;<\/code><\/pre>\n<p>\u4ece\u5de5\u4f5c\u533a\u548c\u6682\u5b58\u533a\u5220\u9664\u4e00\u4e2a\u6587\u4ef6\uff0c\u5e76\u4e14\u5c06\u8fd9\u6b21\u5220\u9664\u653e\u5165\u6682\u5b58\u533a\u3002<\/p>\n<pre><code>git rm --cached &lt;file&gt;<\/code><\/pre>\n<p>\u4ece\u7d22\u5f15\/\u6682\u5b58\u533a\u4e2d\u5220\u9664\u6587\u4ef6\uff0c\u4f46\u662f\u672c\u5730\u5de5\u4f5c\u533a\u6587\u4ef6\u8fd8\u5728\uff0c\u53ea\u662f\u4e0d\u5e0c\u671b\u8fd9\u4e2a\u6587\u4ef6\u88ab\u7248\u672c\u63a7\u5236\u3002<\/p>\n<pre><code>git checkout &lt;file&gt; &lt;commit-id&gt;<\/code><\/pre>\n<p>\u6062\u590d\u4e00\u4e2a\u6587\u4ef6\u5230\u4e4b\u524d\u7684\u7248\u672c\u3002<\/p>\n<pre><code>git revert &lt;commit-id&gt;<\/code><\/pre>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63d0\u4ea4\uff0c\u7528\u6765\u64a4\u9500\u6307\u5b9a\u7684\u63d0\u4ea4\uff0c\u540e\u8005\u7684\u6240\u6709\u53d8\u5316\u5c06\u88ab\u524d\u8005\u62b5\u6d88\uff0c\u5e76\u4e14\u5e94\u7528\u5230\u5f53\u524d\u5206\u652f\u3002<\/p>\n<pre><code>git reset --mixed &lt;commit-id&gt;<\/code><\/pre>\n<p>\u91cd\u7f6e\u5f53\u524d\u5206\u652f\u7684HEAD\u4e3a\u4e4b\u524d\u7684\u67d0\u4e2a\u63d0\u4ea4\uff0c\u5e76\u4e14\u5220\u9664\u6240\u6709\u4e4b\u540e\u7684\u63d0\u4ea4\u3002<\/p>\n<pre><code>hard\u53c2\u6570\u8868\u793a\u91cd\u7f6e\u5de5\u4f5c\u533a\u548c\u6682\u5b58\u533a\uff0c\nsoft\u53c2\u6570\u8868\u793a\u91cd\u7f6e\u6682\u5b58\u533a\uff0c\nmixed\u53c2\u6570\u8868\u793a\u91cd\u7f6e\u5de5\u4f5c\u533a\u3002<\/code><\/pre>\n<pre><code class=\"lang-bash\">git restore --staged &lt;file&gt;<\/code><\/pre>\n<p>\u64a4\u9500\u6682\u5b58\u533a\u7684\u6587\u4ef6\uff0c\u91cd\u65b0\u653e\u56de\u5de5\u4f5c\u533a(git add\u7684\u53cd\u5411\u64cd\u4f5c)\u3002<\/p>\n<h2>git diff\u67e5\u770b\u5dee\u5f02<\/h2>\n<pre><code>git status [-s]<\/code><\/pre>\n<p>\u67e5\u770b\u4ed3\u5e93\u72b6\u6001\uff0c\u5217\u51fa\u8fd8\u672a\u63d0\u4ea4\u7684\u65b0\u7684\u6216\u4fee\u6539\u7684\u6587\u4ef6\u3002$-s$\u662f\u67e5\u770b\u7b80\u7565\u6a21\u5f0f<\/p>\n<pre><code>git log --oneline<\/code><\/pre>\n<p>\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff0c<code>--oneline<\/code>\u8868\u793a\u7b80\u4ecb\u6a21\u5f0f\u3002<\/p>\n<pre><code>git diff<\/code><\/pre>\n<p>\u67e5\u770b\u672a\u6682\u5b58\u7684\u6587\u4ef6\u66f4\u65b0\u4e86\u54ea\u4e9b\u90e8\u5206\u3002<\/p>\n<pre><code>git diff &lt;commit-id&gt; &lt;commit-id&gt;<\/code><\/pre>\n<p>\u67e5\u770b\u4e24\u4e2a\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/p>\n<pre><code>git diff HEAD<\/code><\/pre>\n<p>\u6bd4\u8f83\u5de5\u4f5c\u533a\u4e0e\u6682\u5b58\u533a\u4e4b\u95f4\u7684\u5173\u7cfb<\/p>\n<pre><code>git diff cached<\/code><\/pre>\n<p>\u6bd4\u8f83\u6682\u5b58\u533a\u548c\u7248\u672c\u5e93\u4e4b\u95f4\u7684\u5173\u7cfb<\/p>\n<pre><code>git diff HEAD~ HEAD<\/code><\/pre>\n<p>\u6bd4\u8f83\u5f53\u524d\u7248\u672c\u548c\u4e0a\u4e2a\u7248\u672c<\/p>\n<pre><code>git diff HEAD~x HEAD fil1<\/code><\/pre>\n<p>\u53ef\u4ee5\u7528\u6765\u6bd4\u8f83\u524dx\u4e2a\u7248\u672c\u548c\u73b0\u7248\u672c\u7684\u533a\u522b\uff0c\u540e\u9762\u6dfb\u52a0\u6587\u4ef6\u540d\u53ea\u4f1a\u67e5\u770b\u8be5\u6587\u4ef6\u7684\u533a\u522b<\/p>\n<h2>.gitignore\u5ffd\u7565\u6587\u4ef6<\/h2>\n<p>\u9700\u8981\u5728git\u8fc7\u7a0b\u4e2d\u5ffd\u7565\u6389\u4e00\u4e9b\u6587\u4ef6<\/p>\n<pre><code>.git Git\u4ed3\u5e93\u7684\u5143\u6570\u636e\u548c\u5bf9\u8c61\u6570\u636e\u5e93\n.gitignore \u5ffd\u7565\u6587\u4ef6\uff0c\u4e0d\u9700\u8981\u63d0\u4ea4\u5230\u4ed3\u5e93\u7684\u6587\u4ef6\n.gitattributes \u6307\u5411\u5f53\u524d\u5206\u652f\u7684\u6307\u9488\n.gitkeep \u4f7f\u7a7a\u76ee\u5f55\u88ab\u63d0\u4ea4\u5230\u4ed3\u5e93\n.gitmodules \u8bb0\u5f55\u5b50\u6a21\u5757\u7684\u4fe1\u606f\n.gitconfig \u8bb0\u5f55\u4ed3\u5e93\u7684\u914d\u7f6e\u4fe1\u606f<\/code><\/pre>\n<pre><code>.gitignore\n*.log \/\/\u5ffd\u7565\u67d0\u79cd\u6587\u4ef6\ntemp\/  \/\/\u5ffd\u7565\u6587\u4ef6\u5939\uff0c\u540e\u9762\u662f\u4ee5\/\u7ed3\u5c3e\u7684<\/code><\/pre>\n<p>\u5c31\u8d77\u5230\u4e86\u5ffd\u7565\u6240\u6709log\u7ed3\u5c3e\u7684\u6587\u4ef6\uff0c\u5982\u679c\u5df2\u7ecf\u88ab\u63d0\u4ea4\u5230\u4e86\u7248\u672c\u5e93\u4e2d\u5ffd\u7565\u662f\u6ca1\u6709\u4f5c\u7528\u7684\uff0c\u9700\u8981\u4ece\u6682\u5b58\u533a\u5220\u9664\uff0c\u9700\u8981\u4ec5\u4ec5\u5c06\u8fdc\u7a0b\u5e93\u4e2d\u5220\u9664\u5219\u4f7f\u7528<code>git rm xxx --cached<\/code><\/p>\n<blockquote><p>\u5982\u679c\u4e00\u4e2a\u6587\u4ef6\u5939\u4e0b\u65e0\u6587\u4ef6\u4e0d\u4f1a\u88ab\u6dfb\u52a0\u81f3\u4ed3\u5e93<\/p><\/blockquote>\n<h3>gitignore\u6587\u4ef6\u7684\u5339\u914d\u89c4\u5219<\/h3>\n<ul>\n<li>\u7a7a\u884c\u6216\u8005\u4ee5#\u5f00\u5934\u7684\u884c\u4f1a\u88abGt\u5ffd\u7565\u3002\u4e00\u822c\u7a7a\u884c\u7528\u4e8e\u53ef\u8bfb\u6027\u7684\u5206\u9694\uff0c#\u4e00\u822c\u7528\u4f5c\u6ce8\u91ca<\/li>\n<li>\n<p>\u4f7f\u7528\u6807\u51c6\u7684Blob\u6a21\u5f0f\u5339\u914d\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>\u661f\u53f7*\u901a\u914d\u4efb\u610f\u4e2a\u5b57\u7b26<br \/>\u95ee\u53f7\uff1f\u5339\u914d\u5355\u4e2a\u5b57\u7b26<br \/>\u4e2d\u62ec\u53f7[]\u8868\u793a\u5339\u914d\u5217\u8868\u4e2d\u7684\u5355\u4e2a\u5b57\u7b26\uff0c\u6bd4\u5982\uff1a[abc]\u8868\u793aa\/b\/c<\/p>\n<\/li>\n<li>\u4e24\u4e2a\u661f\u53f7**\u8868\u793a\u5339\u914d\u4efb\u610f\u7684\u4e2d\u95f4\u76ee\u5f55<\/li>\n<li>\n<p>\u4e2d\u62ec\u53f7\u53ef\u4ee5\u4f7f\u7528\u77ed\u4e2d\u7ebf\u8fde\u63a5\uff0c\u6bd4\u5982\uff1a<\/p>\n<p>[0-9]\u8868\u793a\u4efb\u610f\u4e00\u4f4d\u6570\u5b57\uff0c[a-z]\u8868\u793a\u4efb\u610f\u4e00\u4f4d\u5c0f\u5199\u5b57\u6bcd<\/p>\n<\/li>\n<li>\u611f\u53f9\u53f7\uff01\u8868\u793a\u53d6\u53cd<\/li>\n<\/ul>\n<pre><code>#\u5ffd\u7565\u6240\u6709\u7684.a\u6587\u4ef6\n*.a\n#\u4f46\u8ddf\u8e2a\u6240\u6709\u7684lib.a,\u5373\u4fbf\u4f60\u5728\u524d\u9762\u5ffd\u7565\u4e86.a\u6587\u4ef6\n!lib.a\n#\u53ea\u5ffd\u7565\u5f53\u524d\u76ee\u5f55\u4e0b\u7684TODO\u6587\u4ef6\uff0c\u800c\u4e0d\u5ffd\u7565subdir\/T0D0\n\/TODO\n#\u5ffd\u7565\u4efb\u4f55\u76ee\u5f55\u4e0b\u540d\u4e3abuild\u7684\u6587\u4ef6\u5939\nbuild\/\n#\u5ffd\u7565doc\/notes.txt,\u4f46\u4e0d\u5ffd\u7565doc\/server\/arch.txt\ndoc\/*.txt\n#\u5ffd\u7565doc\/\u76ee\u5f55\u53ca\u5176\u6240\u6709\u5b50\u76ee\u5f55\u4e0b\u7684.pdf\u6587\u4ef6\ndoc\/**\/*.pdf<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/github\/gitignore\">\u5e38\u7528\u5ffd\u7565\u6a21\u677f<\/a><\/p>\n<h2>SSH\u914d\u7f6e<\/h2>\n<ol>\n<li>\n<p>\u547d\u4ee4\u884c\u8f93\u5165<code>ssh-keygen<\/code>,\u4e00\u8def\u56de\u8f66\uff0c\u5982\u679c\u8981\u91cd\u65b0\u751f\u6210\u522b\u7684\u5bc6\u94a5\uff0c\u8bf7\u6ce8\u610f\u4fee\u6539\uff0c\u5e76\u4e14\u5728\u67d0\u4e9b\u6307\u5b9a\u7a0b\u5e8f\u4fee\u6539\u8bc6\u522b\u5bc6\u94a5<\/p>\n<p>\u5982\u679c\u66f4\u6362\u4e86\u540d\u79f0\uff0c\u5219\u9700\u8981\u5728<code>.ssh<\/code>\u6587\u4ef6\u5939\u521b\u5efa<code>config<\/code>\u6587\u4ef6\uff0c\u5f53\u6211\u4eec\u4f7f\u7528<code>github<\/code>\u8fc7\u7a0b\u4e2d\u5c31\u4f1a\u9a8c\u8bc1test\u8fd9\u4e2a\u5bc6\u94a5<\/p>\n<pre><code># github\nHost github.com\nHostName github.com\nPreferredAuthentications publickey\nIdentityFile ~\/.ssh\/test<\/code><\/pre>\n<\/li>\n<li>\u53f3\u4e0a\u89d2\u5934\u50cf\u7684<strong>setting<\/strong><\/li>\n<li>\u9875\u9762\u5de6\u4fa7<strong>SSH and GPG keys<\/strong><\/li>\n<li>\u9875\u9762\u4e2d\u95f4<strong>New SSH key<\/strong><\/li>\n<li>\u5c06<code>xxx.pub<\/code>\u8f93\u5165\u5230<code>ssh<\/code>\u5bf9\u8bdd\u6846<\/li>\n<\/ol>\n<h3>\u540c\u6b65\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<pre><code>git push<\/code><\/pre>\n<h3>\u62c9\u53d6\u5230\u672c\u5730\u4ed3\u5e93<\/h3>\n<pre><code>git pull &lt;remote&gt;<\/code><\/pre>\n<h3>\u514b\u9686\u4ed3\u5e93<\/h3>\n<pre><code>git clone repo-address<\/code><\/pre>\n<h2>\u5173\u8054\u8fdc\u7a0b\u4ed3\u5e93\u548c\u672c\u5730\u4ed3\u5e93<\/h2>\n<h3>\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<pre><code>#Step 1\ngit remote add &lt;\u8fdc\u7a0b\u4ed3\u5e93\u522b\u540d&gt; &lt;\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740&gt;\n#Step 2\ngit push -U &lt;\u8fdc\u7a0b\u4ed3\u5e93\u540d&gt; &lt;\u5206\u652f\u540d&gt;<\/code><\/pre>\n<p>\u5728github\u521b\u5efa\u4e00\u4e2a\u4ed3\u5e93<\/p>\n<p>\u70b9\u4e0a\u65b9\u7684ssh\u5e76\u5c06\u4ee3\u7801\u590d\u5236\u5230\u672c\u5730\u7684\u7ec8\u7aef\u8fd0\u884c<\/p>\n<pre><code>git remote add origin git@github.com:geekhall-laoyang\/first-repo.git\ngit branch -M main \/\/\u6307\u5b9a\u5206\u652f\u540d\u79f0\ngit push -u origin main:main \/\/\u672c\u5730main\u5206\u652f\u4e0e\u8fdc\u7a0bmain\u5206\u652f\u5173\u8054\uff0c\u524d\u9762\u7684\u662f\u672c\u5730\uff0c\u540e\u9762\u7684\u662f\u8fdc\u7a0b<\/code><\/pre>\n<h3>\u67e5\u770b\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<pre><code>git remote -v<\/code><\/pre>\n<h3>\u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<pre><code>git pull &lt;\u8fdc\u7a0b\u4ed3\u5e93\u540d&gt;&lt;\u8fdc\u7a0b\u5206\u652f\u540d&gt;:&lt;\u672c\u5730\u5206\u652f\u540d&gt;<\/code><\/pre>\n<p>\u76f8\u540c\u53ef\u4ee5\u7701\u7565\u5192\u53f7\u540e\u9762\u7684<\/p>\n<h2>\u5206\u652f\u64cd\u4f5c<\/h2>\n<ul>\n<li>\u67e5\u770b\u5206\u652f\u5217\u8868\uff1a<\/li>\n<\/ul>\n<pre><code>git branch<\/code><\/pre>\n<ul>\n<li>\u521b\u5efa\u5206\u652f\uff1a<\/li>\n<\/ul>\n<pre><code>git branch branch-name<\/code><\/pre>\n<ul>\n<li>\n<p>\u5207\u6362\u5206\u652f\uff1a<\/p>\n<ul>\n<li>\n<pre><code>git checkout branch-name<\/code><\/pre>\n<\/li>\n<li>\n<pre><code>git switch branch-name<\/code><\/pre>\n<\/li>\n<li>\u8f83\u4e3a\u63a8\u8350\u7b2c\u4e8c\u79cd<\/li>\n<\/ul>\n<\/li>\n<li>\u5408\u5e76\u5206\u652f<\/li>\n<\/ul>\n<pre><code>git merge branch-name<\/code><\/pre>\n<ul>\n<li>\n<p>\u5220\u9664\u5206\u652f\uff1a<\/p>\n<ul>\n<li>[\u5df2\u5408\u5e76]<\/li>\n<li>\n<pre><code>git branch -d branch-name<\/code><\/pre>\n<\/li>\n<li>[\u672a\u5408\u5e76]<\/li>\n<li>\n<pre><code>git branch -D branch-name<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u5408\u5e76<\/h2>\n<h3>\u5408\u5e76\u6b65\u9aa4<\/h3>\n<blockquote><p>\u5728\u63d0\u4ea4\u547d\u4ee4\u52a0\u4e0a-a\u53c2\u6570\u5373\u53ef\u540c\u65f6\u5b8c\u6210\u6682\u5b58\u548c\u63d0\u4ea4\u4e24\u4e2a\u64cd\u4f5c<\/p><\/blockquote>\n<ol>\n<li>\u5207\u6362\u5230\u8981\u88ab\u5408\u5e76\u7684\u5206\u652f<\/li>\n<li>\u8f93\u5165<code>git merge xxx<\/code>\uff0cxxx\u4e3a\u8981\u5408\u5e76\u8fdb\u6765\u7684\u5206\u652f<\/li>\n<li>\u4f7f\u7528<code>git status<\/code>\u67e5\u770b\u51b2\u7a81\u6587\u4ef6<\/li>\n<li>\u4f7f\u7528<code>git diff<\/code>\u67e5\u770b\u51b2\u7a81\u5185\u5bb9<\/li>\n<li>\n<p>\u624b\u52a8\u7f16\u8f91\u51b2\u7a81\u6587\u4ef6\u540e\u518d\u6b21\u63d0\u4ea4<\/p>\n<h3>\u89e3\u51b3\u5408\u5e76\u51b2\u7a81<\/h3>\n<\/li>\n<\/ol>\n<ul>\n<li>\u4e24\u4e2a\u5206\u652f\u672a\u4fee\u6539\u540c\u4e00\u4e2a\u6587\u4ef6\u7684\u540c\u4e00\u5904\u4f4d\u7f6e\uff1aGt\u81ea\u52a8\u5408\u5e76<\/li>\n<li>\n<p>\u4e24\u4e2a\u5206\u652f\u4fee\u6539\u4e86\u540c\u4e00\u4e2a\u6587\u4ef6\u7684\u540c\u4e00\u5904\u4f4d\u7f6e\uff1a\u4ea7\u751f\u51b2\u7a81<\/p>\n<ul>\n<li>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>Step1-\u624b\u5de5\u4fee\u6539\u51b2\u7a81\u6587\u4ef6\uff0c\u5408\u5e76\u51b2\u7a81\u5185\u5bb9<\/li>\n<li>Step2-\u6dfb\u52a0\u6682\u5b58\u533a<code>$ git add file<\/code><\/li>\n<li>Step3-\u63d0\u4ea4\u4fee\u6539<code>$ git commit -m &quot;message&quot;<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\u4e2d\u6b62\u5408\u5e76\uff1a\u5f53\u4e0d\u60f3\u7ee7\u7eed\u6267\u884c\u5408\u5e76\u64cd\u4f5c\u65f6\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u6765\u4e2d\u6b62\u5408\u5e76\u8fc7\u7a0b\uff1a<code>$ git merge --abort<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>rebase<\/h2>\n<pre><code>git rebase dev<\/code><\/pre>\n<p>\u4f8b\u5982\u8fd9\u4e2a\u6307\u4ee4\u5c31\u4f1a\u5c06dev\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\uff0c<code>rebase<\/code>\u7684\u4f5c\u7528\u5c31\u662f\u628a\u547d\u4ee4\u4e2d\u7684\u5206\u652f\u5408\u5e76\u5230\u5f53\u524d\u4f4d\u4e8e\u7684\u5206\u652f<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image-20231124151950658.png\" alt=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\" title=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<ul>\n<li>\u5982\u679c\u5f53\u524d\u5728<code>main<\/code>\u5206\u652f\uff0c\u6267\u884c<code>git rebase dev<\/code>\u540e<br \/><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image-20231124152047736.png\" alt=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\" title=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\"><\/li>\n<li>\u5982\u679c\u5f53\u524d\u5728<code>dev<\/code>\u5206\u652f\uff0c\u6267\u884c<code>git rebase main<\/code>\u540e<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image-20231124152204307.png\" alt=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\" title=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<h3>\u5206\u652f\u7ba1\u7406\u548c\u5de5\u4f5c\u6d41\u6a21\u578b<\/h3>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image-20231124152524780.png\" alt=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\" title=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<h3>\u7248\u672c\u53f7\u89c4\u5219<\/h3>\n<ul>\n<li>\u4e3b\u7248\u672c(Major Version)\uff1a\u4e3b\u8981\u7684\u529f\u80fd\u53d8\u5316\u6216\u91cd\u5927\u66f4\u65b0\uff1b<\/li>\n<li>\u6b21\u7248\u672c(Minor Version)\uff1a\u4e00\u4e9b\u65b0\u7684\u529f\u80fd\u3001\u6539\u8fdb\u548c\u66f4\u65b0\uff0c\u901a\u5e38\u4e0d\u4f1a\u5f71\u54cd\u73b0\u6709\u529f\u80fd\uff1b<\/li>\n<li>\u4fee\u8ba2\u7248\u672c(Patch Version)\uff1a\u4e00\u4e9b\u5c0f\u7684bug\u4fee\u590d\uff0c\u5b89\u5168\u6f0f\u6d1e\u8865\u4e01\u7b49\u3002\u901a\u5e38\u4e0d\u4f1a\u66f4\u6539\u73b0\u6709\u529f\u80fd\u548c\u63a5\u53e3\u3002<\/li>\n<\/ul>\n<h3>\u5206\u652f\u547d\u540d<\/h3>\n<p>\u63a8\u8350\u4f7f\u7528\u5e26\u6709\u610f\u4e49\u7684\u63cf\u8ff0\u6027\u540d\u79f0\u6765\u547d\u540d\u5206\u652f<\/p>\n<ul>\n<li>\u7248\u672c\u53d1\u5e03\u5206\u652f\/Tag\u793a\u4f8b\uff1av1.0.0<\/li>\n<li>\u529f\u80fd\u5206\u652f\u793a\u4f8b\uff1a<code>feature-login-page<\/code><\/li>\n<li>\u4fee\u590d\u5206\u652f\u793a\u4f8b\uff1a<code>hotfix-#fissueid-desc<\/code><\/li>\n<\/ul>\n<h3>\u5206\u652f\u7ba1\u7406<\/h3>\n<ul>\n<li>\u5b9a\u671f\u5408\u5e76\u5df2\u7ecf\u6210\u529f\u9a8c\u8bc1\u7684\u5206\u652f\uff0c\u53ca\u65f6\u5220\u9664\u5df2\u7ecf\u5408\u5e76\u7684\u5206\u652f<\/li>\n<li>\u4fdd\u6301\u5408\u9002\u7684\u5206\u652f\u6570\u91cf<\/li>\n<li>\u4e3a\u5206\u652f\u8bbe\u7f6e\u5408\u9002\u7684\u7ba1\u7406\u6743\u9650<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u521d\u59cb\u5316\u8bbe\u7f6e \u914d\u7f6e\u7528\u6237\u540d git config --global user.name &quot;Your Name&quot; \u914d\u7f6e\u90ae\u7bb1 git config --global user.email &quot;mail@example.com&quot; \u5b58\u50a8\u914d\u7f6e git config --global credential store \u65b0\u5efa\u4ed3\u5e93 \u521b\u5efa\u2f00\u4e2a\u65b0\u7684\u672c\u5730\u4ed3\u5e93\uff08\u7701\u7565project-name \u5219\u5728\u5f53\u524d\u76ee\u5f55\u521b\u5efa\uff09 git init &lt;project-name&gt; \u514b\u9686\u2f00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93 git clone &lt;url&gt; \u5de5\u4f5c\u533a\u57df \u5de5\u4f5c\u533a\uff08Working Directory\uff09 \u5c31\u662f\u4f60\u5728\u7535\u8111\u2fa5\u80fd\u5b9e\u9645\u770b\u5230\u7684\u2f6c\u5f55 \u6682\u5b58\u533a\uff08Stage\/Index\uff09 \u6682\u5b58\u533a\u4e5f\u53eb\u7d22\u5f15\uff0c\u2f64\u6765\u4e34\u65f6\u5b58\u653e\u672a\u63d0\u4ea4\u7684\u5185\u5bb9\uff0c\u2f00\u822c\u5728.git \u2f6c\u5f55\u4e0b\u7684index \u4e2d\u3002 \u672c\u5730\u4ed3\u5e93\uff08Repository\uff09 Git \u5728\u672c\u5730\u7684\u7248\u672c\u5e93\uff0c \u4ed3\u5e93\u4fe1\u606f\u5b58\u50a8\u5728.git \u8fd9\u4e2a\u9690\u85cf\u2f6c\u5f55\u4e2d\u3002 \u8fdc\u7a0b\u4ed3\u5e93\uff08Remote Repository\uff09 \u6258\u7ba1\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u7684\u4ed3\u5e93\u3002 \u5e38\u2f64\u7684\u6709GitHub\uff0c GitLab\uff0c Gitee\u3002 \u6587\u4ef6\u72b6\u6001 \u5df2\u4fee\u6539\uff08Modified\uff09 \u4fee\u6539\u4e86\u4f46\u662f\u6ca1\u6709\u4fdd\u5b58\u5230\u6682\u5b58\u533a\u7684\u2f42\u4ef6 \u5df2\u6682\u5b58\uff08Staged\uff09 \u4fee\u6539\u540e\u5df2\u7ecf\u4fdd\u5b58\u5230\u6682\u5b58\u533a\u7684\u2f42\u4ef6 \u5df2\u63d0\u4ea4\uff08Committed\uff09 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-git"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=274"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}