新建文件:mkdir tmp
进入文件:cd tmp
初始化:git init
配置用户名和邮箱:
<code class="hljs fsharp has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">git config --<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">global</span> user.name <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"zhujin"</span> git config --<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">global</span> user.email <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"zhuj@126.com"</span></code>
<code class="hljs livecodeserver has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">ssh-keygen -t rsa -C <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"<span style="color: rgb(0, 136, 0); font-family: 'Source Code Pro', monospace; font-size: 14px; white-space: pre; background-color: rgba(128, 128, 128, 0.0470588);">zhuj@126.com</span>"</span> </code>
<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">cat ~/<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.ssh</span>/id_rsa<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.pub</span></code>
将出现的内容复制到服务器端
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">vi ~<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/.ssh/config</span></code>
内容如下:
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">Hostname serverip(修改为你访问的git库的服务器IP) KexAlgorithms <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">+</span>diffie<span class="hljs-attribute" style="box-sizing: border-box;">-hellman</span><span class="hljs-attribute" style="box-sizing: border-box;">-group1</span><span class="hljs-attribute" style="box-sizing: border-box;">-sha1</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>