windows下的git 安装与使用以及大概遇到问题
一、安装部门:首先关于git安装,直接从官网下载即可下载地点为:Git - Downloads (git-scm.com)
安装上面没什么需要注意的,一路next下来即可。
二、环境配置:
1.安装好之后设置姓名和邮箱(注意这里的邮箱和姓名为github官网GitHub注册所使用的邮箱以及用户名)
设置方式为使用管理员身份打开git bash,输入:
git config --global user.name "UserName"
git config --global user.email "your_email@example.com"
此时有大概会出现错误一 error:could not lock config file
大多的教程为设置环境变量,但是也有设置完环境变量之后仍然会报错的情况,因此需要进一步对文件的权限进行设置。
第一步打开高级系统设置进入修改环境变量
https://i-blog.csdnimg.cn/blog_migrate/2683e7c74a23113397ae3175bcf9e417.png
https://i-blog.csdnimg.cn/blog_migrate/957e91805d9839bb0a3581aec9c0f9ec.png
第二步:将Git Bash设置为管理员身份运行,Git Bash->右键->属性->兼容性->勾选“以管理员身份运行此步伐”
https://i-blog.csdnimg.cn/blog_migrate/e20ca5483b0c295e73cff1a0b74e8044.png
https://i-blog.csdnimg.cn/blog_migrate/9c35cf6ab751ffc1dec9febe1caed957.png
第三步:修改etc文件夹的权限
打开Git/mingw64->右键etc文件夹->安全->编辑->添加->高级->查找->立刻查找->Everyone
勾选完全控制权限。
https://i-blog.csdnimg.cn/blog_migrate/c744435a817364e7ebc4fe74a42c0d29.png
https://i-blog.csdnimg.cn/blog_migrate/8bf613f37463c9df9fd0a030a1011604.png
https://i-blog.csdnimg.cn/blog_migrate/e89b5c3802be3ab0ff2bb7318a054bb5.png
完成之后就不会出现设置用户名和邮箱error了
2.设置SSHKey
ssh-keygen -t rsa -C "your_email@example.com"
此处我在Git Bash中无法实行。大概会出现错误二:Saving key "//.ssh/id_rsa" failed: No such file or directory
https://i-blog.csdnimg.cn/blog_migrate/72140a38326613b0526364985d718aac.png
在“命令提示符”以管理员运行后输入可以实行
https://i-blog.csdnimg.cn/blog_migrate/630799d25b71559be821326c80e02710.png
此时windows对应的路径下面出现相对应的文件表示生成成功。
https://i-blog.csdnimg.cn/blog_migrate/f7df7e638fafef2f0883b9bed89d26c9.png
在Git Bash中检察相对应的文件cat Users/win/.ssh/id_rsa.pub
出现报错三:No such file or directory 产生这个错误的缘故原由是工作区的设置问题,无法在默认的工作区内找到相应的文件
https://i-blog.csdnimg.cn/blog_migrate/f2e84e53fca935fe7302c13a49b204dd.png
之后在实行cat Users/win/.ssh/id_rsa.pub成功https://i-blog.csdnimg.cn/blog_migrate/62b8a5026873a4b1b1b4b7969d5d9141.png
三、实现通过ssh将当地与github的连接
1.首先按照以下操作将ssh公钥添加到github
https://i-blog.csdnimg.cn/blog_migrate/01ccea25c1717d127a58f2a3fba82f5a.png
https://i-blog.csdnimg.cn/blog_migrate/63fe225d65fffda8de04b251166d077f.png
https://i-blog.csdnimg.cn/blog_migrate/8030da906966d6e93f19c780e5dbb401.png
添加成功之后就会收到一封公共秘钥添加完成的邮件。完成上述过程之后就可以使用手中的私钥与github进行认证通讯了。
ssh -T git@github.com
此时出现错误四:Permission denied(publickey)的缘故原由大概是因为没有将公钥添加到当地ssh环境中造成的
https://i-blog.csdnimg.cn/blog_migrate/ffc358f43cabd7ca0c9cadcd96e346a7.png
ssh-add /Users/win/.ssh/id_rsa
如果实行词条代码,出现Could not open a connection to your authentication agent,则需要启动链接输入ssh-agent bash,然后再次输入ssh-add /Users/win/.ssh/id_rsa则能够成功完成添加。
https://i-blog.csdnimg.cn/blog_migrate/8d56ccc38aee5bf3a1c8243671005ae9.pnghttps://i-blog.csdnimg.cn/blog_migrate/fdd16f6574565ac338e2f4d7467ebb86.png
再次输入ssh -T git@github.com就能够完成
https://i-blog.csdnimg.cn/blog_migrate/8f37475fd30384e4d96a4ccac0522665.png
完成上述操作之后便可以从github中以ssh的方式下载堆栈中的项目到当地。
四、项目的拉取与更新
可以在github官网中创建一个项目
https://i-blog.csdnimg.cn/blog_migrate/5a715e9004f1c9edb5d17fba50e2cb54.png
https://i-blog.csdnimg.cn/blog_migrate/37276b19f51eb8bc6bab02209ce62aab.png
1.通过clone的方式完成拉取
https://i-blog.csdnimg.cn/blog_migrate/40c12d3b672ddc63ec01ed4c8d9b17c7.png
2.在当地创建新文件(或者对于已有的文件完成修改)
https://i-blog.csdnimg.cn/blog_migrate/caa21561b67a4bb573e7440298dabf0c.png
3.将修改后的文件上传更新
git add hello_world.php 将文件加入暂存区
git commit -m "Add hello world script by php" 提交文件
git push github上的堆栈就会被更新
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]