Linux 配置gitee
<p>安装好git后, 如何配置连接至gitee ?<br>首先, 需要在官网注册一个gitee账号, 然后进行以下配置步骤:</p>
<h3 id="1-设置账号">1. 设置账号</h3>
<pre><code class="language-bash">$ git config --global user.name "your name"
</code></pre>
<h3 id="2-设置邮箱">2. 设置邮箱</h3>
<pre><code class="language-bash">$ git config --global user.email "your email"
</code></pre>
<h3 id="3-生成密钥">3. 生成密钥</h3>
<pre><code class="language-c">$ ssh-keygen -t rsa -C "your email"
</code></pre>
<h3 id="4-查看生成的公钥">4. 查看生成的公钥</h3>
<pre><code class="language-bash">$ cat ~/.ssh/id_rsa.pub
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQDxFVh... (一段字符串, 最后是你的邮箱. 具体内容这里省略)
</code></pre>
<h3 id="5-复制至gitee">5. 复制至gitee</h3>
<p>打开gitee官网, 设置->SSH公钥->添加 SSH公钥.<br>
标题可以任意设置, 生成的公钥id_rsa.pub内容复制到gitee官网这里, 就可以添加SSH公钥了了.</p>
<p><img src="https://img2020.cnblogs.com/blog/741401/202105/741401-20210531173515322-239302781.png" alt="" loading="lazy"></p>
<h3 id="6-测试验证是否连接成功">6. 测试验证是否连接成功</h3>
<pre><code class="language-bash">$ ssh -T git@gitee.com
</code></pre>
<p>如出现以下欢迎信息, 说明连接成功, 进一步证明上面的配置正确. 否则, 请仔细检查上面的步骤.</p>
<pre><code class="language-bash">Hi xxx! You've successfully authenticated, but GITEE.COM does not provide shell access.
</code></pre>
<h3 id="faq">FAQ</h3>
<p>1)查看当前已配置全局用户, 邮箱</p>
<pre><code class="language-bash">$ git config --global -l
user.name=yourusername
user.email=youremail@xxx.com
</code></pre>
<p>单独查看已配置用户名,邮箱</p>
<pre><code class="language-bash">$ git config user.name
yourusername
$ git config user.email
youremail@xxx.com
</code></pre>
<p>2)修改配置的全局用户, 邮箱<br>
同第一次配置</p>
<pre><code class="language-bash">$ git config --global user.name "yourusername"
$ git config --global user.email "youremail@xxx.com"
</code></pre>
<p>3)测试是否连接成功</p>
<pre><code class="language-bash">$ ssh -T git@gitee.com
</code></pre>
<p>4)指定要生成密钥/公钥 文件名<br>
i.g. 指定用于github,gitee的密钥/公钥文件名</p>
<pre><code class="language-bash">//Gitee SSH-key生成命令
$ ssh-keygen -t rsa -C 'xxxxx@xxx.com' -f ~/.ssh/github_id_rsa
//GitHub SSH-key生成命令
$ ssh-keygen -t rsa -C 'xxxxx@xxx.com' -f ~/.ssh/gitee_id_rsa
</code></pre>
<h3 id="参考">参考</h3>
<p> SSH 公钥设置 | Gitee官网</p><br><br>
来源:https://www.cnblogs.com/fortunely/p/14832446.html
頁:
[1]