<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://www.bigdick.live/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https:&#x2F;&#x2F;www.bigdick.live</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>这是Web Feed，又称为Atom Feed，把现在的网址复制到新闻阅读器即可订阅本站文章。造访「About Feeds」来了解更多资讯。</tabi:about_feeds>
        <tabi:visit_the_site>造访网站</tabi:visit_the_site>
        <tabi:recent_posts>近期文章</tabi:recent_posts>
        <tabi:last_updated_on>更新于 $DATE</tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>Git</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://www.bigdick.live/skins/black-orange.css?h=c64b7f81e34a143cd725" /><title>孙瑜 - Git</title>
        <subtitle>孙瑜的个人首页：生物信息、数据科学、软件工程，以及公开简历、项目和文章。</subtitle>
    <link href="https://www.bigdick.live/tags/git/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://www.bigdick.live/tags/git/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2018-06-27T00:00:00+00:00</updated><id>https://www.bigdick.live/tags/git/atom.xml</id><entry xml:lang="zh-Hans">
        <title>Git该如何免密码提交？</title>
        <published>2018-06-27T00:00:00+00:00</published>
        <updated>2018-06-27T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/gitmian-mi-ma-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/gitmian-mi-ma-zh/</id>
        
            <content type="html">&lt;p&gt;早年的时候比较迷，看到GitHub上的ssh key和repo的ssh地址总是傻傻不知道有什么用…然后使用GitLab的private仓库的时候因为强制要求使用ssh key感到很迷茫（因为在GitHub根本用不起）（什么？Student Pack？）（什么？不知道5个根本不够用吗2333333）。今天终于抽点时间解释一下来给后人看。&lt;&#x2F;p&gt;
&lt;p&gt;直到前阵子幡然醒悟，md老子这么久以来为什么一直在用账号密码提交代码？&lt;&#x2F;p&gt;
&lt;p&gt;本文中就不以CMD举例了，反正看这个东西的人，你肯定有一个git bash，这比CMD好用n倍，那么命令都是一样的。&lt;&#x2F;p&gt;
&lt;p&gt;先查看当前用户有已经生成的ssh公钥吗：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; ~&#x2F;.ssh&#x2F;id_rsa.pub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;如果没有，从头生成一个：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;ssh-keygen&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-punctuation z-definition z-string&quot;&gt; -C &amp;quot;你可以写邮箱，但是无所谓，不加这个参数都无所谓&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;嗯，就是这么简单，对于普通用户而言，什么&lt;code&gt;-t&lt;&#x2F;code&gt;啊&lt;code&gt;-b&lt;&#x2F;code&gt;啊，忘了它们吧。
中间还会提示你选个路径&#x2F;文件名去存放这个key，无所谓，默认最好了，方便。
中间还会提示你输入一个“短语”，我去你*的短语，这就是密码啊…这个可能得找个小本本悄悄记下来了hhhhh，一路回车，然后再来一轮：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; ~&#x2F;.ssh&#x2F;id_rsa.pub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;是不是有内容了！是不是敲厉害！默默把标准输出复制下来吧！&lt;&#x2F;p&gt;
&lt;p&gt;然后去GitHub（当然GitLab什么的同理啦）找到设置再找到SSH key那项，选择New（账户设置啊，别去repo设置玩半天），把之前复制的内容贴进去。写个妥善的Title（比如这是你何年何月何日在何地结缘的电脑，网吧什么的你还是别搞什么SSH key这种幺蛾子了），让自己记住是干嘛用的。&lt;&#x2F;p&gt;
&lt;p&gt;好了，这个时候估计你就会和以前的我一样开始玩蛋：
兴高采烈地push了一波发现输入账号和密码的提示又出来了！
因为你其实之前就是通过https方式访问repo的，改成ssh就好了，比如这样：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;git&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; remote rm origin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;git&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; remote add origin git@你那个仓库的地址（详见下图）.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;当然，如果你之前没有clone过仓库，那就直接从git地址克隆就没毛病了。&lt;&#x2F;p&gt;
&lt;p&gt;之后再push就无痛了。&lt;&#x2F;p&gt;
</content>
        </entry>
</feed>
