{"id":199,"date":"2026-04-25T18:47:14","date_gmt":"2026-04-25T10:47:14","guid":{"rendered":"https:\/\/pc.wuhanioe.com\/index.php\/2026\/04\/25\/git-%e6%8f%90%e4%ba%a4%e6%8e%a8%e9%80%81%e6%80%bb%e5%a4%b1%e8%b4%a5%ef%bc%9f%e4%bb%8e%e5%87%ad%e8%af%81%e3%80%81%e5%88%86%e6%94%af%e5%88%b0%e9%92%a9%e5%ad%90%e7%9a%84%e5%85%a8%e9%93%be%e8%b7%af\/"},"modified":"2026-04-25T18:47:14","modified_gmt":"2026-04-25T10:47:14","slug":"git-%e6%8f%90%e4%ba%a4%e6%8e%a8%e9%80%81%e6%80%bb%e5%a4%b1%e8%b4%a5%ef%bc%9f%e4%bb%8e%e5%87%ad%e8%af%81%e3%80%81%e5%88%86%e6%94%af%e5%88%b0%e9%92%a9%e5%ad%90%e7%9a%84%e5%85%a8%e9%93%be%e8%b7%af","status":"publish","type":"post","link":"https:\/\/pc.wuhanioe.com\/index.php\/2026\/04\/25\/git-%e6%8f%90%e4%ba%a4%e6%8e%a8%e9%80%81%e6%80%bb%e5%a4%b1%e8%b4%a5%ef%bc%9f%e4%bb%8e%e5%87%ad%e8%af%81%e3%80%81%e5%88%86%e6%94%af%e5%88%b0%e9%92%a9%e5%ad%90%e7%9a%84%e5%85%a8%e9%93%be%e8%b7%af\/","title":{"rendered":"Git \u63d0\u4ea4\u63a8\u9001\u603b\u5931\u8d25\uff1f\u4ece\u51ed\u8bc1\u3001\u5206\u652f\u5230\u94a9\u5b50\u7684\u5168\u94fe\u8def\u6392\u67e5"},"content":{"rendered":"<p>Git \u7684\u62a5\u9519\u4fe1\u606f\u5e38\u8ba9\u4eba\u6478\u4e0d\u7740\u5934\u8111\uff1a\u540c\u6837\u662f\u5931\u8d25\uff0c\u53ef\u80fd\u662f\u8d26\u53f7\u5bc6\u7801\u9519\uff0c\u4e5f\u53ef\u80fd\u662f\u5206\u652f\u88ab\u4fdd\u62a4\uff0c\u751a\u81f3\u662f\u672c\u5730\u94a9\u5b50\u62e6\u4e86\u4f60\u3002\u672c\u6587\u6309\u51fa\u73b0\u9891\u7387\u68b3\u7406\u6700\u5e38\u89c1\u7684\u51e0\u7c7b\u5931\u8d25\uff0c\u5e76\u7ed9\u51fa\u53ef\u76f4\u63a5\u7167\u505a\u7684\u4fee\u590d\u6b65\u9aa4\u3002<\/p>\n<h2>\u4e00\u3001\u8ba4\u8bc1\u5931\u8d25\uff1aremote: Invalid username or password<\/h2>\n<p><strong>\u73b0\u4ee3\u4ee3\u7801\u6258\u7ba1\u51e0\u4e4e\u90fd\u7981\u7528\u4e86\u660e\u6587\u5bc6\u7801\uff0c\u5fc5\u987b\u7528\u4ee4\u724c\uff08token\uff09<\/strong>\u3002\u6392\u67e5\uff1a<\/p>\n<ol>\n<li>\u786e\u8ba4\u7528\u7684\u662f\u4e2a\u4eba\u8bbf\u95ee\u4ee4\u724c\u800c\u975e\u767b\u5f55\u5bc6\u7801\uff1bGitHub\/GitLab \u5728 2021 \u5e74\u540e\u5747\u8981\u6c42 token\u3002<\/li>\n<li>Windows \u51ed\u636e\u7ba1\u7406\u5668\u91cc\u53ef\u80fd\u7f13\u5b58\u4e86\u65e7\u5bc6\u7801\uff1a\u6253\u5f00\u300e\u51ed\u636e\u7ba1\u7406\u5668 \u2192 Windows \u51ed\u636e\u300f\uff0c\u5220\u6389 <code>git:https:\/\/...<\/code> \u6761\u76ee\uff0c\u4e0b\u6b21\u63a8\u9001\u91cd\u65b0\u8f93\u5165\u3002<\/li>\n<li>\u7528 SSH \u53ef\u4e00\u52b3\u6c38\u9038\uff1a\u751f\u6210 <code>ssh-keygen -t ed25519<\/code>\uff0c\u628a\u516c\u94a5\u52a0\u5230\u8d26\u6237\uff0c\u5e76\u628a remote \u6539\u4e3a <code>git@host:user\/repo.git<\/code>\u3002<\/li>\n<\/ol>\n<h2>\u4e8c\u3001non-fast-forward\uff1a\u672c\u5730\u843d\u540e\u4e8e\u8fdc\u7aef<\/h2>\n<ol>\n<li>\u62a5\u9519\u542b <code>failed to push some refs<\/code> \u548c <code>non-fast-forward<\/code>\uff0c\u8bf4\u660e\u522b\u4eba\u5df2\u63a8\u9001\u65b0\u63d0\u4ea4\u3002<\/li>\n<li>\u5148 <code>git pull --rebase<\/code> \u628a\u672c\u5730\u63d0\u4ea4\u53d8\u57fa\u5230\u6700\u65b0\uff0c\u518d <code>git push<\/code>\u3002<\/li>\n<li>\u82e5 pull \u62a5\u51b2\u7a81\uff0c\u9010\u6587\u4ef6\u89e3\u51b3\u540e <code>git add<\/code> \u518d <code>git rebase --continue<\/code>\u3002<\/li>\n<\/ol>\n<h2>\u4e09\u3001\u5206\u652f\u88ab\u4fdd\u62a4\u6216\u6743\u9650\u4e0d\u8db3<\/h2>\n<p><strong>\u76f4\u63a5\u5411 main\/master \u63a8\u9001\u5e38\u88ab\u670d\u52a1\u7aef\u62d2\u7edd<\/strong>\u3002\u6b64\u65f6\u5e94\uff1a<\/p>\n<ol>\n<li>\u65b0\u5efa\u7279\u6027\u5206\u652f\uff1a<code>git checkout -b feature\/x<\/code>\uff0c\u63a8\u5230\u8fdc\u7aef\u540e\u518d\u8d70\u5408\u5e76\u8bf7\u6c42\uff08MR\/PR\uff09\u3002<\/li>\n<li>\u82e5\u662f\u6743\u9650\u95ee\u9898\uff0c\u62a5\u9519\u901a\u5e38\u542b <code>remote: You are not allowed to push<\/code>\uff0c\u9700\u8054\u7cfb\u4ed3\u5e93\u7ba1\u7406\u5458\u6388\u6743\u3002<\/li>\n<\/ol>\n<h2>\u56db\u3001pre-commit \/ pre-push \u94a9\u5b50\u62e6\u622a<\/h2>\n<ol>\n<li>\u94a9\u5b50\u62a5\u9519\u5f62\u5982 <code>husky - pre-commit hook failed<\/code>\uff0c\u672c\u8d28\u662f\u672c\u5730\u68c0\u67e5\u672a\u8fc7\uff08\u5982 lint\u3001\u6d4b\u8bd5\uff09\u3002<\/li>\n<li>\u5148\u8bfb\u94a9\u5b50\u8f93\u51fa\uff0c\u4fee\u590d\u5bf9\u5e94\u95ee\u9898\uff1b\u786e\u5c5e\u8bef\u62a5\u53ef <code>git commit --no-verify<\/code> \u4e34\u65f6\u7ed5\u8fc7\uff0c\u4f46\u9700\u8c28\u614e\u3002<\/li>\n<\/ol>\n<h2>\u4e94\u3001\u5927\u6587\u4ef6\u4e0e\u914d\u989d\u9650\u5236<\/h2>\n<p>\u5355\u4e2a\u6587\u4ef6\u8d85\u8fc7\u6258\u7ba1\u9650\u5236\uff08\u5982 GitHub 100MB\uff09\u4f1a\u62d2\u7edd\u3002\u5e94\u6539\u7528 Git LFS\uff1a<code>git lfs install<\/code> \u540e <code>git lfs track '*.psd'<\/code>\uff0c\u518d\u63d0\u4ea4\uff1b\u5df2\u8bef\u63d0\u4ea4\u7684\u9700 <code>git filter-repo<\/code> \u6e05\u7406\u5386\u53f2\u3002<\/p>\n<p><strong>\u6280\u672f\u5c0f\u7ed3\uff1a<\/strong>Git \u63a8\u9001\u5931\u8d25\u5148\u8bfb\u5b8c\u6574\u62a5\u9519\u9996\u884c\uff0c\u5206\u6e05\u300e\u8ba4\u8bc1 \/ \u843d\u540e \/ \u6743\u9650 \/ \u94a9\u5b50 \/ \u4f53\u79ef\u300f\u4e94\u7c7b\uff0c\u518d\u5bf9\u75c7\u4e0b\u836f\u3002\u517b\u6210\u300e\u5148 pull &#8211;rebase \u518d push\u3001\u7528\u4ee4\u724c\u4e0e SSH\u300f\u7684\u4e60\u60ef\uff0c\u53ef\u89c4\u907f\u516b\u6210\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8986\u76d6\u8ba4\u8bc1\u5931\u8d25\u3001\u5206\u652f\u51b2\u7a81\u3001\u94a9\u5b50\u62e6\u622a\u4e0e\u5927\u5c0f\u9650\u5236\uff0c\u7cfb\u7edf\u89e3\u51b3 Git \u63a8\u9001\u95ee\u9898\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-199","post","type-post","status-publish","format-standard","hentry","category-3"],"_links":{"self":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts\/199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/comments?post=199"}],"version-history":[{"count":0,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts\/199\/revisions"}],"wp:attachment":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/media?parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/categories?post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/tags?post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}