{"id":10020753,"date":"2025-04-19T09:39:12","date_gmt":"2025-04-19T01:39:12","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020753"},"modified":"2025-04-19T09:39:12","modified_gmt":"2025-04-19T01:39:12","slug":"mac-%e4%b8%8a%e4%bd%bf%e7%94%a8-homebrew-%e5%ae%89%e8%a3%85-git%ef%bc%8c%e5%b9%b6%e9%85%8d%e7%bd%ae-git-%e7%94%a8%e6%88%b7%e5%90%8d%e5%92%8c%e9%82%ae%e7%ae%b1%e7%9a%84%e8%af%a6%e7%bb%86%e6%95%99","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020753","title":{"rendered":"Mac \u4e0a\u4f7f\u7528 Homebrew \u5b89\u88c5 Git\uff0c\u5e76\u914d\u7f6e Git \u7528\u6237\u540d\u548c\u90ae\u7bb1\u7684\u8be6\u7ec6\u6559\u7a0b"},"content":{"rendered":"<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 Mac \u4e0a\u901a\u8fc7 Homebrew \u5b89\u88c5 Git\uff0c\u5e76\u914d\u7f6e Git \u7528\u6237\u540d\u548c\u90ae\u7bb1\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n<hr>\n<h3><strong>\u6b65\u9aa4 1\uff1a\u5b89\u88c5 Homebrew\uff08\u5982\u679c\u672a\u5b89\u88c5\uff09<\/strong><\/h3>\n<p>\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5b89\u88c5 Homebrew\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u5b83\u3002\u6253\u5f00 <strong>\u7ec8\u7aef<\/strong>\uff08Terminal\uff09\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5 Homebrew\uff1a<\/p>\n<pre><code class=\"bash\">\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/code><\/pre>\n<p>\u6309\u7167\u5c4f\u5e55\u4e0a\u7684\u63d0\u793a\uff0cHomebrew \u4f1a\u88ab\u5b89\u88c5\u5230 <code>\/opt\/homebrew<\/code> \u76ee\u5f55\uff08\u5bf9\u4e8e Apple Silicon Mac\uff09\u6216\u8005 <code>\/usr\/local<\/code> \u76ee\u5f55\uff08\u5bf9\u4e8e Intel Mac\uff09\u3002<\/p>\n<p><strong>\u5b89\u88c5\u6210\u529f\u540e\uff0c\u7ec8\u7aef\u4e2d\u4f1a\u8f93\u51fa\u76f8\u5173\u7684\u5b89\u88c5\u4fe1\u606f\u3002<\/strong><\/p>\n<hr>\n<h3><strong>\u6b65\u9aa4 2\uff1a\u4f7f\u7528 Homebrew \u5b89\u88c5 Git<\/strong><\/h3>\n<p>\u5b89\u88c5\u5b8c Homebrew \u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5 Git\uff1a<\/p>\n<pre><code class=\"bash\">brew install git<\/code><\/pre>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5 Git\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0cHomebrew \u4f1a\u8f93\u51fa Git \u7248\u672c\u4fe1\u606f\uff0c\u786e\u8ba4 Git \u5b89\u88c5\u6210\u529f\u3002<\/p>\n<hr>\n<h3><strong>\u6b65\u9aa4 3\uff1a\u68c0\u67e5 Git \u5b89\u88c5\u662f\u5426\u6210\u529f<\/strong><\/h3>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1 Git \u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<pre><code class=\"bash\">git --version<\/code><\/pre>\n<p>\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u7ec8\u7aef\u4f1a\u663e\u793a\u7c7b\u4f3c\u5982\u4e0b\u7684\u4fe1\u606f\uff1a<\/p>\n<pre><code class=\"bash\">git version 2.x.x<\/code><\/pre>\n<p>\u8868\u793a\u4f60\u5df2\u7ecf\u6210\u529f\u5b89\u88c5\u4e86 Git\u3002<\/p>\n<hr>\n<h3><strong>\u6b65\u9aa4 4\uff1a\u914d\u7f6e Git \u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1<\/strong><\/h3>\n<p>Git \u4f7f\u7528\u7528\u6237\u540d\u548c\u90ae\u7bb1\u6765\u6807\u8bc6\u6bcf\u6b21\u63d0\u4ea4\u3002\u4e3a\u4e86\u8ba9 Git \u77e5\u9053\u4f60\u7684\u8eab\u4efd\uff0c\u4f60\u9700\u8981\u914d\u7f6e Git \u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1\u3002<\/p>\n<h4>4.1. \u914d\u7f6e\u5168\u5c40\u7528\u6237\u540d\u548c\u90ae\u7bb1<\/h4>\n<p>\u4f60\u53ef\u4ee5\u5168\u5c40\u914d\u7f6e\u4e00\u4e2a\u7528\u6237\u540d\u548c\u90ae\u7bb1\uff0c\u8fd9\u6837\u6240\u6709\u7684 Git \u4ed3\u5e93\u90fd\u4f1a\u4f7f\u7528\u8fd9\u4e2a\u914d\u7f6e\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u914d\u7f6e\u7528\u6237\u540d\uff1a<\/p>\n<pre><code class=\"bash\">git config --global user.name &quot;Your Name&quot;<\/code><\/pre>\n<p>\u7136\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u914d\u7f6e\u4f60\u7684\u90ae\u7bb1\uff1a<\/p>\n<pre><code class=\"bash\">git config --global user.email &quot;your-email@example.com&quot;<\/code><\/pre>\n<p>\u5728\u4e0a\u8ff0\u547d\u4ee4\u4e2d\uff0c\u66ff\u6362 <code>&quot;Your Name&quot;<\/code> \u4e3a\u4f60\u81ea\u5df1\u7684\u540d\u5b57\uff0c\u66ff\u6362 <code>&quot;your-email@example.com&quot;<\/code> \u4e3a\u4f60\u81ea\u5df1\u7684\u90ae\u7bb1\u5730\u5740\u3002<\/p>\n<h4>4.2. \u914d\u7f6e\u5f53\u524d\u4ed3\u5e93\u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1<\/h4>\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u4e3a\u67d0\u4e2a\u7279\u5b9a\u7684 Git \u4ed3\u5e93\u914d\u7f6e\u4e0d\u540c\u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1\uff0c\u53ef\u4ee5\u5728\u8be5\u4ed3\u5e93\u76ee\u5f55\u4e0b\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"bash\">git config user.name &quot;Your Repo Name&quot;\ngit config user.email &quot;your-repo-email@example.com&quot;<\/code><\/pre>\n<p>\u8fd9\u5c06\u53ea\u5f71\u54cd\u5f53\u524d Git \u4ed3\u5e93\uff0c\u5176\u4ed6\u4ed3\u5e93\u4ecd\u7136\u4f7f\u7528\u5168\u5c40\u914d\u7f6e\u3002<\/p>\n<hr>\n<h3><strong>\u6b65\u9aa4 5\uff1a\u67e5\u770b Git \u914d\u7f6e<\/strong><\/h3>\n<p>\u914d\u7f6e\u597d\u7528\u6237\u540d\u548c\u90ae\u7bb1\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b Git \u914d\u7f6e\uff1a<\/p>\n<ul>\n<li>\u67e5\u770b\u5168\u5c40\u7528\u6237\u540d\uff1a<\/li>\n<\/ul>\n<pre><code class=\"bash\">git config --global user.name<\/code><\/pre>\n<ul>\n<li>\u67e5\u770b\u5168\u5c40\u90ae\u7bb1\uff1a<\/li>\n<\/ul>\n<pre><code class=\"bash\">git config --global user.email<\/code><\/pre>\n<ul>\n<li>\u67e5\u770b\u5f53\u524d\u4ed3\u5e93\u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1\uff08\u5982\u679c\u4f60\u5728\u4e00\u4e2a\u4ed3\u5e93\u5185\uff09\uff1a<\/li>\n<\/ul>\n<pre><code class=\"bash\">git config user.name\ngit config user.email<\/code><\/pre>\n<ul>\n<li>\u67e5\u770b\u6240\u6709\u7684 Git \u914d\u7f6e\u4fe1\u606f\uff1a<\/li>\n<\/ul>\n<pre><code class=\"bash\">git config --list<\/code><\/pre>\n<p>\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u914d\u7f6e\uff0c\u5305\u62ec\u7528\u6237\u540d\u3001\u90ae\u7bb1\u3001git \u7f16\u8f91\u5668\u7b49\u4fe1\u606f\u3002<\/p>\n<hr>\n<h3><strong>\u6b65\u9aa4 6\uff1a\u9a8c\u8bc1\u914d\u7f6e<\/strong><\/h3>\n<p>\u4e3a\u786e\u4fdd\u4e00\u5207\u6b63\u5e38\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 Git \u8fdb\u884c\u4e00\u6b21\u63d0\u4ea4\u64cd\u4f5c\uff0c\u786e\u8ba4\u7528\u6237\u540d\u548c\u90ae\u7bb1\u662f\u5426\u751f\u6548\u3002\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u4ed3\u5e93\uff0c\u6dfb\u52a0\u4e00\u4e9b\u6587\u4ef6\uff0c\u5e76\u8fdb\u884c\u63d0\u4ea4\uff1a<\/p>\n<pre><code class=\"bash\"># \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Git \u4ed3\u5e93\nmkdir test-repo\ncd test-repo\ngit init\n\n# \u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\u5e76\u6dfb\u52a0\u5185\u5bb9\necho &quot;Hello, Git!&quot; &gt; test.txt\ngit add test.txt\n\n# \u63d0\u4ea4\u6587\u4ef6\ngit commit -m &quot;Initial commit&quot;<\/code><\/pre>\n<p>\u7136\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1\u662f\u5426\u6b63\u786e\uff1a<\/p>\n<pre><code class=\"bash\">git log --oneline<\/code><\/pre>\n<p>\u8fd9\u4f1a\u663e\u793a\u63d0\u4ea4\u4fe1\u606f\uff0c\u5305\u62ec\u7528\u6237\u540d\u548c\u90ae\u7bb1\u3002<\/p>\n<hr>\n<h3><strong>\u603b\u7ed3<\/strong><\/h3>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5df2\u7ecf\u6210\u529f\u5730\u4f7f\u7528 Homebrew \u5b89\u88c5\u4e86 Git\uff0c\u5e76\u914d\u7f6e\u4e86 Git \u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1\u3002\u4f60\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528 Git \u6765\u7ba1\u7406\u4ee3\u7801\uff0c\u6267\u884c\u7248\u672c\u63a7\u5236\u4efb\u52a1\u3002\u5e0c\u671b\u8fd9\u4e2a\u6559\u7a0b\u5bf9\u4f60\u6709\u5e2e\u52a9\uff01<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000046452582\">https:\/\/segmentfault.com\/a\/1190000046452582<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 Mac \u4e0a\u901a\u8fc7 Homebrew \u5b89\u88c5 Git\uff0c\u5e76\u914d\u7f6e Git \u7528\u6237\u540d\u548c\u90ae\u7bb1\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002 \u6b65\u9aa4  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020753","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020753"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020753\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}