{"id":261,"date":"2025-09-10T09:19:52","date_gmt":"2025-09-10T01:19:52","guid":{"rendered":"http:\/\/43.139.99.192\/?p=261"},"modified":"2025-09-10T09:19:52","modified_gmt":"2025-09-10T01:19:52","slug":"%e5%b8%b8%e7%94%a8git%e5%91%bd%e4%bb%a4%e9%80%9f%e6%9f%a5%e8%a1%a8","status":"publish","type":"post","link":"http:\/\/43.139.99.192\/index.php\/2025\/09\/10\/%e5%b8%b8%e7%94%a8git%e5%91%bd%e4%bb%a4%e9%80%9f%e6%9f%a5%e8%a1%a8\/","title":{"rendered":"\u5e38\u7528Git\u547d\u4ee4\u901f\u67e5\u8868"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4e00\u3001\u73af\u5883\u914d\u7f6e<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u547d\u4ee4 \u4f5c\u7528 \u793a\u4f8b<br>git &#8211;version \u9a8c\u8bc1\u5b89\u88c5 git &#8211;version<br>git config &#8211;global user.name &#8220;\u540d\u5b57&#8221; \u8bbe\u7f6e\u5168\u5c40\u7528\u6237\u540d git config &#8211;global user.name &#8220;John&#8221;<br>git config &#8211;global user.email &#8220;\u90ae\u7bb1&#8221; \u8bbe\u7f6e\u5168\u5c40\u90ae\u7bb1 git config &#8211;global user.email &#8220;john@example.com&#8221;<br>git config &#8211;global core.editor &#8220;\u7f16\u8f91\u5668&#8221; \u8bbe\u7f6e\u9ed8\u8ba4\u6587\u672c\u7f16\u8f91\u5668 git config &#8211;global core.editor &#8220;code &#8211;wait&#8221;<br>\u4e8c\u3001\u672c\u5730\u4ed3\u5e93\u64cd\u4f5c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u547d\u4ee4 \u4f5c\u7528 \u793a\u4f8b<br>git init \u521d\u59cb\u5316\u65b0\u4ed3\u5e93 git init<br>git status \u67e5\u770b\u5de5\u4f5c\u533a\/\u6682\u5b58\u533a\u72b6\u6001 git status<br>git add &lt;\u6587\u4ef6&gt; \u6dfb\u52a0\u6587\u4ef6\u5230\u6682\u5b58\u533a git add index.html<br>git add . \u6dfb\u52a0\u6240\u6709\u4fee\u6539\u5230\u6682\u5b58\u533a git add .<br>git commit -m &#8220;\u8bf4\u660e&#8221; \u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93 git commit -m &#8220;\u521d\u59cb\u5316\u9879\u76ee&#8221;<br>git log \u67e5\u770b\u63d0\u4ea4\u5386\u53f2 git log &#8211;oneline &#8211;graph<br>git diff \u67e5\u770b\u5de5\u4f5c\u533a\u4e0e\u6682\u5b58\u533a\u5dee\u5f02 git diff<br>\u4e09\u3001\u5206\u652f\u4e0e\u5408\u5e76<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u547d\u4ee4 \u4f5c\u7528 \u793a\u4f8b<br>git branch \u67e5\u770b\u672c\u5730\u5206\u652f git branch<br>git branch &lt;\u5206\u652f\u540d&gt; \u521b\u5efa\u65b0\u5206\u652f git branch feature-login<br>git checkout &lt;\u5206\u652f\u540d&gt; \u5207\u6362\u5206\u652f git checkout main<br>git switch &lt;\u5206\u652f\u540d&gt; (\u63a8\u8350) \u5207\u6362\u5206\u652f git switch feature<br>git merge &lt;\u5206\u652f\u540d&gt; \u5408\u5e76\u5206\u652f\u5230\u5f53\u524d\u5206\u652f git merge feature<br>git branch -d &lt;\u5206\u652f\u540d&gt; \u5220\u9664\u5206\u652f git branch -d fix-bug<br>\u56db\u3001\u8fdc\u7a0b\u4ed3\u5e93\u534f\u4f5c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u547d\u4ee4 \u4f5c\u7528 \u793a\u4f8b<br>git remote add &lt;\u522b\u540d&gt; \u5173\u8054\u8fdc\u7a0b\u4ed3\u5e93 git remote add origin https:\/\/\u2026<br>git clone \u514b\u9686\u8fdc\u7a0b\u4ed3\u5e93 git clone https:\/\/github.com\/xxx.git<br>git push -u &lt;\u8fdc\u7a0b&gt; &lt;\u5206\u652f&gt; \u9996\u6b21\u63a8\u9001\u5206\u652f git push -u origin main<br>git push \u63a8\u9001\u66f4\u6539\uff08\u5df2\u5173\u8054\u5206\u652f\uff09 git push<br>git pull \u62c9\u53d6\u8fdc\u7a0b\u66f4\u65b0\uff08\u81ea\u52a8\u5408\u5e76\uff09 git pull origin main<br>git fetch \u4ec5\u83b7\u53d6\u8fdc\u7a0b\u66f4\u65b0\uff08\u4e0d\u5408\u5e76\uff09 git fetch<br>\u4e94\u3001\u64a4\u9500\u4e0e\u4fee\u590d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u547d\u4ee4 \u4f5c\u7528 \u98ce\u9669\u7b49\u7ea7<br>git restore &lt;\u6587\u4ef6&gt; \u64a4\u9500\u5de5\u4f5c\u533a\u4fee\u6539 \u26a0\ufe0f \u8986\u76d6\u672c\u5730\u66f4\u6539<br>git restore &#8211;staged &lt;\u6587\u4ef6&gt; \u4ece\u6682\u5b58\u533a\u64a4\u56de\u6587\u4ef6 \u5b89\u5168<br>git commit &#8211;amend \u4fee\u6539\u6700\u65b0\u63d0\u4ea4\uff08\u4fe1\u606f\/\u5185\u5bb9\uff09 \u4f4e\u98ce\u9669<br>git reset &#8211;soft HEAD~1 \u64a4\u9500\u63d0\u4ea4\u4f46\u4fdd\u7559\u66f4\u6539 \u4e2d\u98ce\u9669<br>git reset &#8211;hard HEAD~1 \u5f7b\u5e95\u4e22\u5f03\u6700\u8fd1\u63d0\u4ea4 \u26a0\ufe0f\ufe0f \u9ad8\u5371\uff08\u6570\u636e\u4e22\u5931\uff09<br>git revert &lt;\u63d0\u4ea4ID&gt; \u521b\u5efa\u65b0\u63d0\u4ea4\u6765\u64a4\u9500\u65e7\u63d0\u4ea4 \u5b89\u5168<br>\u516d\u3001\u9ad8\u7ea7\u7ef4\u62a4<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u547d\u4ee4 \u4f5c\u7528 \u793a\u4f8b<br>git tag v1.0 \u521b\u5efa\u7248\u672c\u6807\u7b7e git tag v1.0<br>git stash \u4e34\u65f6\u50a8\u85cf\u4fee\u6539 git stash<br>git stash pop \u6062\u590d\u50a8\u85cf\u7684\u4fee\u6539 git stash pop<br>git rm &#8211;cached &lt;\u6587\u4ef6> \u4eceGit\u79fb\u9664\u6587\u4ef6\uff08\u4fdd\u7559\u672c\u5730\uff09 git rm &#8211;cached .env<br>git reflog \u67e5\u770b\u64cd\u4f5c\u5386\u53f2\uff08\u6551\u547d\u547d\u4ee4\uff09 git reflog<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u73af\u5883\u914d\u7f6e \u547d\u4ee4 \u4f5c\u7528 \u793a\u4f8bgit &#8211;version \u9a8c\u8bc1\u5b89\u88c5 git &#8211;versi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-261","post","type-post","status-publish","format-standard","hentry","category-text"],"_links":{"self":[{"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/posts\/261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/comments?post=261"}],"version-history":[{"count":1,"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":262,"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/posts\/261\/revisions\/262"}],"wp:attachment":[{"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/43.139.99.192\/index.php\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}