1.新建远程仓库
下载和安装git(傻瓜方式next)
![](https://img-blog.csdnimg.cn/68cc68df0d8842749bf2fcc4bea9326e.png)
![](https://img-blog.csdnimg.cn/32701995ae7e4db3b350c275668b0497.png)
登录或注册账号
![](https://img-blog.csdnimg.cn/28feb2d71ccc4f0dbf5c6431f7557b3e.png)
进入界面创建仓库
![](https://img-blog.csdnimg.cn/5be84d70a26848738977b5d1a06c4f02.png)
![](https://img-blog.csdnimg.cn/c952e62190504751a708e730cc64a7ac.png)
![](https://img-blog.csdnimg.cn/cb5d344198cb478b8d07c063b2acd17b.png)
1.2添加ssh公钥并下载项目
![](https://img-blog.csdnimg.cn/2a4ce09ba32a4abc8724fd91e29c3031.png)
![](https://img-blog.csdnimg.cn/45680cacc11741a3a908c2cb6a4b907f.png)
![](https://img-blog.csdnimg.cn/28824d0f378f46e7bddede1dd25e3433.png)
![](https://img-blog.csdnimg.cn/18f74ade59c54ddcba33c2d023cb08c9.png)
![](https://img-blog.csdnimg.cn/aff9783172264ae09e3e86c9dd0154b0.png)
![](https://img-blog.csdnimg.cn/524c42391cda489eafc75310a05d78da.png)
![](https://img-blog.csdnimg.cn/be0a8b68c2c84ef888f4c9004d5307a4.png)
![](https://img-blog.csdnimg.cn/501c528c1b9a476a88ab630c7cacdd11.png)
![](https://img-blog.csdnimg.cn/07b43a5f2fae4b71adc26aec57f9409c.png)
![](https://img-blog.csdnimg.cn/01ab7989a5b9485a8795e11011e16d6b.png)
![](https://img-blog.csdnimg.cn/60b6db5fde9d469a9df909cd2d27142a.png)
![](https://img-blog.csdnimg.cn/73dae673179c4958ac6c88404a708d5d.png)
用vscode打开随便建一个文件
![](https://img-blog.csdnimg.cn/7b7034e8bb38475991feb97b772eb4ec.png)
1.3git创建分支和切换分支
相当于分支是队员们的一套代码,主支是组长的,队员在分支的代码编写不影响主支,分支的队员把代码写好了最后交给主支组长合并就可以了
![](https://img-blog.csdnimg.cn/17d5091036c94349ac25b22a0617c2e7.png)
![](https://img-blog.csdnimg.cn/098fcd7b7c2d44e28064c79786b72fd2.png)
![](https://img-blog.csdnimg.cn/ba40e3bbe46d426392728e017d6a69a2.png)
![](https://img-blog.csdnimg.cn/07f4c392bc1e4aa8bfa95fdba5d7c033.png)
![](https://img-blog.csdnimg.cn/635f04101a174f58a7a6ad4e5d310f53.png)
切换分支 之前必须先把修改的代码提交
![](https://img-blog.csdnimg.cn/eed21f01c5df4dc2b3b3c549f808f20c.png)
合并中的代码冲突解决(同一个文件的同一行代码不相同)
![](https://img-blog.csdnimg.cn/0c5fe4d5bbb842bbbd4aa48ec7c16269.png)
git reset --hard版本号实现代码回滚
![](https://img-blog.csdnimg.cn/41492d259a904584998513dcce04fbf6.png)
![](https://img-blog.csdnimg.cn/8aa7f86f441d4e3a9f8a7c5f119b2c05.png)
总结:
1.工作区(git add . )-> 暂存区(git commit -m "描述") ->本地仓库(git push) ->远程仓库(git pull) ->工作区
2.
git init
git config --global user.name "ydyr"
git config --global user.email "ydyr@163.com"
git add .
git commit -m "第一次提交"
git push origin master
如有错误,愿各位大佬指错,别忘记点赞收藏加关注噢!!!
你们的关注是我创作的最大动力。
一、git作用
1.不会生成新的文件,只会在源文件的基础上修改。
2.在这维护的几年间中,不会有成千上万文件,只会有一个文件。
3.所有的更改信息都会记录在版本控制系统里,如果想回到之前的版本,只要执行对应的操作
4.协同合作 :在他改完后能知道他最新的情况,并再在他的基础上修改
二、git安装
1.找到git官网,直接找到对应的版本进行默认安装
2.检测是否安装成功(右击git bash here)git --version
![](https://img-blog.csdnimg.cn/d57fd3ccb2534a89b81f576de7523eef.png)
3.简单配置-----查看设置好的配置信息(git config --global --list)
![](https://img-blog.csdnimg.cn/cb0d6930dea349b88b0472446318c2fe.png)
3.1简单配置-----重新设置用户名和邮箱
![](https://img-blog.csdnimg.cn/af5b90415ec34b5fadad9be251676f7f.png)
4.建立git仓库--------已经存在的项目
![](https://img-blog.csdnimg.cn/353ee3b9fbaa40d2b221827c431ee835.png)
![](https://img-blog.csdnimg.cn/8677f6b297e543cdb719a804d56f32b7.png)
![](https://img-blog.csdnimg.cn/baa0298f8bf34f10a434eb88beb10c62.png)
4.1再重新建一个项目
![](https://img-blog.csdnimg.cn/3c8a5e4f196644f995b6d297cec59aa6.png)
4.3对某一个仓库进行配置
![](https://img-blog.csdnimg.cn/8065d1db54974702a3be8615bab50e4b.png)
git config --local 只对仓库有效
git config --global只对登录用户仓库有效
git config --system 对系统的所有用户有效
5.提交版本信息
![](https://img-blog.csdnimg.cn/25b910456e8f4c298dba41b6209a31a5.png)
![](https://img-blog.csdnimg.cn/5c3f1c3d173646dfbbd6c8d4d86ec20d.png)
![](https://img-blog.csdnimg.cn/b9893a72cd6c40379fba18b40733148d.png)
版本状态查看
![](https://img-blog.csdnimg.cn/789d00b7d2d44187939737c3478e4661.png)
修改了的文件![](https://img-blog.csdnimg.cn/2dcadf50f534409794929f2a9fd7d07a.png)
![](https://img-blog.csdnimg.cn/dd836d1c09264502b00f2eb29882a3a3.png)
![](https://img-blog.csdnimg.cn/9a17615d075b42779489034b0bbe7231.png)
![](https://img-blog.csdnimg.cn/3ea335da6f6e4ac19dfac44613ecec2f.png)
git push提交上去就ok了