{"id":83,"date":"2025-09-22T15:55:14","date_gmt":"2025-09-22T07:55:14","guid":{"rendered":"https:\/\/zcc609.online\/?p=83"},"modified":"2025-09-22T15:55:14","modified_gmt":"2025-09-22T07:55:14","slug":"4-git%e5%85%8d%e5%af%86%e6%8b%89%e5%8f%96%e5%92%8c%e7%bb%88%e7%ab%af%e8%87%aa%e5%8a%a8%e8%a1%a5%e5%85%a8%e5%ae%8c%e6%95%b4%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/zcc609.online\/?p=83","title":{"rendered":"4.Git\u514d\u5bc6\u62c9\u53d6\u548c\u7ec8\u7aef\u81ea\u52a8\u8865\u5168\u5b8c\u6574\u914d\u7f6e\u6307\u5357"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"\ud83c\udfaf-\u76ee\u6807\">\ud83c\udfaf \u76ee\u6807<\/h2>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u914d\u7f6eGit SSH\u514d\u5bc6\u62c9\u53d6\uff0c\u907f\u514d\u6bcf\u6b21\u8f93\u5165\u5bc6\u94a5\u5bc6\u7801<\/li>\n\n\n\n<li>\u914d\u7f6eZsh\u7ec8\u7aef\u81ea\u52a8\u8865\u5168\u529f\u80fd<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\ud83d\udccb-\u7b2c\u4e00\u90e8\u5206\uff1aGit-SSH\u514d\u5bc6\u914d\u7f6e\">\ud83d\udccb \u7b2c\u4e00\u90e8\u5206\uff1aGit SSH\u514d\u5bc6\u914d\u7f6e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1.-\u68c0\u67e5\u5f53\u524dGit\u4ed3\u5e93\u914d\u7f6e\">1. \u68c0\u67e5\u5f53\u524dGit\u4ed3\u5e93\u914d\u7f6e<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\">git remote -v<\/mark><\/code><\/pre>\n\n\n\n<p>\u76ee\u7684\uff1a\u786e\u8ba4\u4ed3\u5e93\u4f7f\u7528SSH URL\u683c\u5f0f\uff08git@git.woa.com:&#8230;\uff09\u800c\u975eHTTPS<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2.-\u68c0\u67e5SSH\u5bc6\u94a5\u72b6\u6001\">2. \u68c0\u67e5SSH\u5bc6\u94a5\u72b6\u6001<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>1# \u68c0\u67e5ssh-agent\u4e2d\u7684\u5bc6\u94a52ssh-add -l3\u200b4# \u68c0\u67e5SSH\u5bc6\u94a5\u6587\u4ef65ls -la ~\/.ssh\/<\/code><\/pre>\n\n\n\n<p>\u53d1\u73b0\u95ee\u9898\uff1assh-agent\u4e2d\u6ca1\u6709\u52a0\u8f7d\u4efb\u4f55\u8eab\u4efd\u9a8c\u8bc1<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3.-\u521b\u5efaSSH\u914d\u7f6e\u6587\u4ef6\">3. \u521b\u5efaSSH\u914d\u7f6e\u6587\u4ef6<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cat > ~\/.ssh\/config &lt;&lt; 'EOF'\nHost *\n    AddKeysToAgent yes\n    UseKeychain yes\n    IdentitiesOnly yes\n\nHost git.woa.com\n    HostName git.woa.com\n    User git\n    IdentityFile ~\/.ssh\/id_rsa\n    AddKeysToAgent yes\n    UseKeychain yes\nEOF<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4.-\u8bbe\u7f6eSSH\u914d\u7f6e\u6587\u4ef6\u6743\u9650\">4. \u8bbe\u7f6eSSH\u914d\u7f6e\u6587\u4ef6\u6743\u9650<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 600 ~\/.ssh\/config<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5.-\u5c06SSH\u5bc6\u94a5\u6dfb\u52a0\u5230macOS-Keychain\">5. \u5c06SSH\u5bc6\u94a5\u6dfb\u52a0\u5230macOS Keychain<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-add --apple-use-keychain ~\/.ssh\/id_rsa<\/code><\/pre>\n\n\n\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u9700\u8981\u8f93\u5165\u4e00\u6b21SSH\u5bc6\u94a5\u7684\u5bc6\u7801\u77ed\u8bed\uff0c\u4e4b\u540e\u4f1a\u4fdd\u5b58\u5230keychain<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6.-\u9a8c\u8bc1Git\u514d\u5bc6\u529f\u80fd\">6. \u9a8c\u8bc1Git\u514d\u5bc6\u529f\u80fd<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git status2git pull<\/code><\/pre>\n\n\n\n<p><strong>\u7ed3\u679c<\/strong>\uff1a\u65e0\u9700\u518d\u8f93\u5165SSH\u5bc6\u94a5\u5bc6\u7801<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\ud83d\udccb-\u7b2c\u4e8c\u90e8\u5206\uff1aZsh\u7ec8\u7aef\u81ea\u52a8\u8865\u5168\u914d\u7f6e\">\ud83d\udccb \u7b2c\u4e8c\u90e8\u5206\uff1aZsh\u7ec8\u7aef\u81ea\u52a8\u8865\u5168\u914d\u7f6e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1.-\u68c0\u67e5\u5f53\u524dShell\u914d\u7f6e\">1. \u68c0\u67e5\u5f53\u524dShell\u914d\u7f6e<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>echo $SHELL2cat ~\/.zshrc<\/code><\/pre>\n\n\n\n<p>\u53d1\u73b0\u95ee\u9898\uff1a.zshrc\u914d\u7f6e\u7b80\u5355\uff0c\u7f3a\u5c11\u81ea\u52a8\u8865\u5168\u529f\u80fd<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2.-\u521b\u5efa\u5b8c\u6574\u7684.zshrc\u914d\u7f6e\u6587\u4ef6\">2. \u521b\u5efa\u5b8c\u6574\u7684.zshrc\u914d\u7f6e\u6587\u4ef6<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u7f16\u8f91 ~\/.zshrc \u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a\n# \u5728\u591a\u4e2a shell \u4f1a\u8bdd\u4e4b\u95f4\u5171\u4eab\u5386\u53f2\u8bb0\u5f55\nsetopt SHARE_HISTORY\n\n# PATH \u914d\u7f6e\nexport PATH=~\/.npm-global\/bin:$PATH\nexport PATH=\"$PATH:$HOME\/.npm-global\/bin\"\nexport PATH=\"\/Users\/skkyyu\/.codebuddy\/bin:$PATH\"\n\n# ===== \u57fa\u7840\u81ea\u52a8\u8865\u5168\u914d\u7f6e =====\n# \u542f\u7528\u81ea\u52a8\u8865\u5168\u7cfb\u7edf\nautoload -Uz compinit\ncompinit\n\n# \u542f\u7528\u83dc\u5355\u9009\u62e9\u6a21\u5f0f\nzstyle ':completion:*' menu select\n\n# \u5927\u5c0f\u5199\u4e0d\u654f\u611f\u8865\u5168\nzstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'\n\n# \u663e\u793a\u8865\u5168\u63cf\u8ff0\nzstyle ':completion:*' verbose true\n\n# \u8865\u5168\u7f13\u5b58\nzstyle ':completion:*' use-cache on\nzstyle ':completion:*' cache-path ~\/.zsh\/cache\n\n# \u989c\u8272\u652f\u6301\nautoload -U colors &amp;&amp; colors\nzstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}\n\n# \u5386\u53f2\u8bb0\u5f55\u914d\u7f6e\nHISTFILE=~\/.zsh_history\nHISTSIZE=10000\nSAVEHIST=10000\nsetopt HIST_IGNORE_DUPS\nsetopt HIST_IGNORE_SPACE\nsetopt HIST_VERIFY\nsetopt APPEND_HISTORY\nsetopt INC_APPEND_HISTORY\n\n# \u57fa\u7840\u63d0\u793a\u7b26\nPROMPT='%F{green}%n@%m%f %F{blue}%~%f %# '\n\n# \u542f\u7528\u66f4\u591a\u8865\u5168\u9009\u9879\nsetopt AUTO_LIST\nsetopt AUTO_MENU\nsetopt COMPLETE_IN_WORD\nsetopt ALWAYS_TO_END\n\n# Git \u5206\u652f\u663e\u793a\uff08\u7b80\u5316\u7248\uff09\nautoload -Uz vcs_info\nprecmd() { vcs_info }\nzstyle ':vcs_info:git:*' formats ' (%b)'\nsetopt PROMPT_SUBST\nPROMPT='%F{green}%n@%m%f %F{blue}%~%f%F{red}${vcs_info_msg_0_}%f %# '\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3.-\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\">3. \u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>source ~\/.zshrc<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4.-\u9a8c\u8bc1\u81ea\u52a8\u8865\u5168\u529f\u80fd\">4. \u9a8c\u8bc1\u81ea\u52a8\u8865\u5168\u529f\u80fd<\/h3>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<pre class=\"wp-block-code\"><code># \u6d4b\u8bd5\u547d\u4ee4\u8865\u5168\ngit &lt;Tab>           # \u5e94\u663e\u793agit\u5b50\u547d\u4ee4\nls \/Us&lt;Tab>         # \u5e94\u8865\u5168\u8def\u5f84\ncd ~\/Do&lt;Tab>        # \u5e94\u8865\u5168\u76ee\u5f55\u540d<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\ud83d\udd27-\u5173\u952e\u914d\u7f6e\u8bf4\u660e\">\ud83d\udd27 \u5173\u952e\u914d\u7f6e\u8bf4\u660e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"SSH\u914d\u7f6e\u6587\u4ef6\u5173\u952e\u53c2\u6570\uff1a\">SSH\u914d\u7f6e\u6587\u4ef6\u5173\u952e\u53c2\u6570\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>AddKeysToAgent yes<\/code>\uff1a\u81ea\u52a8\u6dfb\u52a0\u5bc6\u94a5\u5230ssh-agent<\/li>\n\n\n\n<li><code>UseKeychain yes<\/code>\uff1a\u4f7f\u7528macOS keychain\u5b58\u50a8\u5bc6\u94a5<\/li>\n\n\n\n<li><code>IdentitiesOnly yes<\/code>\uff1a\u53ea\u4f7f\u7528\u6307\u5b9a\u7684\u8eab\u4efd\u6587\u4ef6<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Zsh\u81ea\u52a8\u8865\u5168\u5173\u952e\u914d\u7f6e\uff1a\">Zsh\u81ea\u52a8\u8865\u5168\u5173\u952e\u914d\u7f6e\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>autoload -Uz compinit; compinit<\/code>\uff1a\u542f\u7528\u8865\u5168\u7cfb\u7edf<\/li>\n\n\n\n<li><code>zstyle ':completion:*' menu select<\/code>\uff1a\u542f\u7528\u83dc\u5355\u9009\u62e9<\/li>\n\n\n\n<li><code>matcher-list 'm:{a-z}={A-Za-z}'<\/code>\uff1a\u5927\u5c0f\u5199\u4e0d\u654f\u611f<\/li>\n\n\n\n<li><code>setopt AUTO_MENU<\/code>\uff1a\u81ea\u52a8\u663e\u793a\u8865\u5168\u83dc\u5355<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u2705-\u6700\u7ec8\u6548\u679c\">\u2705 \u6700\u7ec8\u6548\u679c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Git\u64cd\u4f5c\u5b8c\u5168\u514d\u5bc6\uff1a\">Git\u64cd\u4f5c\u5b8c\u5168\u514d\u5bc6\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>git pull<\/code>\u3001<code>git push<\/code>\u3001<code>git fetch<\/code> \u65e0\u9700\u5bc6\u7801<\/li>\n\n\n\n<li>SSH\u5bc6\u94a5\u5bc6\u7801\u4fdd\u5b58\u5728macOS keychain\u4e2d<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u7ec8\u7aef\u81ea\u52a8\u8865\u5168\u529f\u80fd\uff1a\">\u7ec8\u7aef\u81ea\u52a8\u8865\u5168\u529f\u80fd\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Tab\u952e\u667a\u80fd\u8865\u5168\u547d\u4ee4\u548c\u8def\u5f84<\/li>\n\n\n\n<li>\u83dc\u5355\u9009\u62e9\u6a21\u5f0f\uff0c\u65b9\u5411\u952e\u9009\u62e9\u9009\u9879<\/li>\n\n\n\n<li>\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u5339\u914d<\/li>\n\n\n\n<li>Git\u5206\u652f\u663e\u793a\u5728\u63d0\u793a\u7b26\u4e2d<\/li>\n\n\n\n<li>\u5386\u53f2\u547d\u4ee4\u641c\u7d22\uff08Ctrl+R\uff09<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u5957\u914d\u7f6e\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u5f00\u53d1\u73af\u5883\u4f18\u5316\uff0c\u5927\u5927\u63d0\u5347\u4e86\u547d\u4ee4\u884c\u4f7f\u7528\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ud83c\udfaf \u76ee\u6807 \ud83d\udccb \u7b2c\u4e00\u90e8\u5206\uff1aGit SSH\u514d\u5bc6\u914d\u7f6e 1. \u68c0\u67e5\u5f53\u524dGit\u4ed3\u5e93\u914d\u7f6e \u76ee\u7684\uff1a\u786e\u8ba4\u4ed3\u5e93\u4f7f\u7528SSH URL &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/zcc609.online\/?p=83\" class=\"more-link\">Read more<span class=\"screen-reader-text\"> &#8220;4.Git\u514d\u5bc6\u62c9\u53d6\u548c\u7ec8\u7aef\u81ea\u52a8\u8865\u5168\u5b8c\u6574\u914d\u7f6e\u6307\u5357&#8221;<\/span><\/a><\/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-83","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zcc609.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=83"}],"version-history":[{"count":1,"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions"}],"predecessor-version":[{"id":84,"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions\/84"}],"wp:attachment":[{"href":"https:\/\/zcc609.online\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zcc609.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zcc609.online\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}