github的拉取、提交,创建分支与合并,删除仓库及分支
前期准备:
1、安装git
官网地址:https://git-scm.com/(下载下来,直接下一步)
2、github账号(这有点废话)
3、配置github密钥
下载及安装好git后,右击桌面,找到git Bash Here,
打开输入:ssh-keygen -t rsa -C 你的邮箱
比如: ssh-keygen -t rsa -C ccsd@.com
然后就一直下一步
箭头标的是.ssh的地址,(我以前安装过,要不然可能程序会多点),打开本地文件,找到.ssh的目录,点进去会有个id_rsa.pub文件,用记事本打开,复制里面的内容
在github点击头像的下拉框,Settings点进去
找到SSH and GPG keys点击,再点击New SSH key(以前我配置过)
Title随便写,key就把在id_rsa.pub文件里复制的内容粘贴到里面就行了,点击Add SSH key就大功告成了!
一:拉取
先在本地新建一个文件夹;
进入当前创建的文件夹,打开git Bash Here,输入:git init,则文件夹中会出现一个.git的文件夹(如果没有则是默认隐藏了,没关系的!)
登录github账号,
点加号里面的new repository创建一个仓库
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302154338840-1605861607.png)
进入填写名称,说明,勾选Initialize this repository with a README,
在点击Create repository点击确认创建仓库。
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302154435391-754252262.png)
然后在本地新建文件夹里面打开Git Bash Here,
git clone url(指mark项目的地址)
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302154517735-251178933.png)
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302154550052-28710397.png)
完成之后项目就被克隆在本地仓库里了。
二、提交项目到github
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302154756893-509252850.png)
进入项目目录
再在当前目录放入要放入的项目
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302154838007-1031837034.png)
执行:git add .
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302154910115-1678783729.png)
执行:git commit -m “提交项目的说明文字”
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302154957129-1523310813.png)
执行:git remote add origin url(mark仓库的地址) 让本地仓库与远程仓库关联
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302155038323-1389047435.png)
执行:git push origin master 本地仓库的代码提交到github上(期间要输入用户名和密码,也就是github上面的账号密码)
三、创建分支,提交到分支再合并
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302155501941-494315917.png)
执行: git branch test 创建一个test的分支
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302155543988-210649932.png)
执行: git checkout test 切换到test分支
mark本地仓库上添加新的需要上传的代码
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302155708587-1580667521.png)
执行: git add .
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302155758920-1460231769.png)
执行: git commit -m "提交代码的说明"
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302155828759-111592979.png)
执行: git remote add origin url(mark仓库的地址)
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302155906176-527441721.png)
执行:git push origin test 本地仓库的代码提交到github上(期间要输入用户名和密码,也就是github上面的账号密码)
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302155949434-1715040891.png)
会出行compare&pull request ,点击进去
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302160022234-989526319.png)
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302160105925-1276427447.png)
![](https://images2018.cnblogs.com/blog/1259861/201803/1259861-20180302160116680-329799023.png)
点击合并,则test分支的代码就合并到master主干上了。
当前操作完成,这大功告成!
提示:再次祝大家元宵快乐,希望此篇文章对大家有帮助,在前端还有很长的路,再次自勉!
再次知道一些github上的操作,特此记录下
删除项目中的多余分支
命令行: git push origin :分支名称
![](https://images2018.cnblogs.com/blog/1259861/201804/1259861-20180425100833046-448698481.png)
当前我的分支名称为stars,则直接输入当前命令就行
删除github上创建的多余仓库
先进入当前github上的仓库中,点击当前项目中的settings
进去滑到最下面,点击delete this repository
再刷新项目,则当前仓库就没有了