学习成长

提供在线文档,方便大家学习


Git配置管理----环境搭建和使用1

<h3>Windows----Github环境搭建</h3> <h4>一、下载安装</h4> <p>下载地址: <a href="https://git-for-windows.github.io/">https://git-for-windows.github.io/</a> 在官方下载完后,安装到Windows Explorer integration的时候,将选项中将“Git Bash here”和“Git GUI here”勾选,之后就一直next直到Finish。</p> <h4>二、github使用</h4> <p>参考:<a href="https://blog.csdn.net/hcbbt/article/details/11651229">https://blog.csdn.net/hcbbt/article/details/11651229</a></p> <h5>1.注册账户以及创建仓库</h5> <p>要想使用github第一步当然是注册github账号了。之后就可以创建仓库了(免费用户只能建公共仓库),Create a New Repository,填好名称后Create,之后会出现一些仓库的配置信息,这也是一个git的简单教程。</p> <h5>2.安装客户端msysgit</h5> <p>github是服务端,要想在自己电脑上使用git我们还需要一个git客户端,我这里选用msysgit,这个只是提供了git的核心功能,而且是基于命令行的。如果想要图形界面的话只要在msysgit的基础上安装TortoiseGit即可。</p> <p>装完msysgit后右键鼠标会多出一些选项来,在本地仓库里右键选择Git Init Here,会多出来一个.git文件夹,这就表示本地git创建成功。右键Git Bash进入git命令行,为了把本地的仓库传到github,还需要配置ssh key。</p> <h5>3.配置Git</h5> <p>首先在本地创建ssh key; </p> <p>ssh-keygen -t rsa -C &quot;zhangsan@youremail.com&quot; 后面的zhangsan@youremail.com改为你的邮箱,之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/12e7497443f189418804fe338192f6da?showdoc=.jpg" alt="" /></p> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/1b76d7d7e1718ff7873a1902a95ae08c?showdoc=.jpg" alt="" /></p> <p>回到github,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填,粘贴key。为了验证是否成功,在git bash下输入:</p> <p>$ ssh -T git@github.com</p> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/88f96fefa363020f8168ac3b69b5d7df?showdoc=.jpg" alt="" /> 如果是第一次的会提示是否continue,输入yes就会看到:You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。</p> <p>接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。</p> <p>$ git config --global user.name &quot;your name&quot; $ git config --global user.email &quot;your_email@youremail.com&quot; 进入要上传的仓库,右键git bash,添加远程地址:</p> <p>$ git remote add origin git@github.com:yourName/yourRepo.git 后面的yourName和yourRepo表示你再github的用户名和刚才新建的仓库,加完之后进入.git,打开config,这里会多出一个remote “origin”内容,这就是刚才添加的远程地址,也可以直接修改config来配置远程地址。</p>

页面列表

ITEM_HTML