type
status
date
slug
summary
tags
category
icon
password
AI summary
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/image-20220813212436756.png?t=f83c5610-e812-4d84-975a-eb6fca2476f8)
Author:ShineVersion:9.0.2
[TOC]
一、引言
在单人开发过程中,需要进行版本管理,以利于开发进度的控制。在多人开发过程中,不仅需要版本管理,还需要进行多人协同控制。
二、介绍
Git是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。官网:https://git-scm.com/
三、Git安装
3.1 下载Git
下载Git https://git-scm.com/downloads
下载git
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/install1.jpg?t=397d9f5c-d316-481e-9336-430d36c4b560)
3.2 安装
安装,除了安装位置外,其他一直下一步即可
3.3 基本配置
安装后,打开cmd ,自报家门如下信息会在提交代码时要使用,记录在你的每次提交中。以后才知道哪次提交是谁做的。
3.4 测试
测试:cmd中执行 ,查看git版本
四、架构
版本库:工作区中有一个隐藏目录 .git,这个目录不属于工作区,而是git的 版本库,是git管理的所有内容暂存区:版本库中包含一个临时区域,保存下一步要提交的文件。分支:版本库中包含若干分支,提交的文件存储在分支中
架构图
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%9A%82%E5%AD%98%E5%8C%BA.jpg?t=e8e3c8b9-84f1-45e5-acca-8b0c0891d2ce)
五、仓库
对应的就是一个目录,这个目录中的所有文件被git管理起来。以后会将一个项目的根目录,作为仓库。仓库中的每个文件的改动 都由git跟踪。
5.1 新建仓库
选择一个目录,执行指令:git init
5.2 工作区
执行git init的目录即为工作区,如上例,D:\repo1目录即为工作区【不包含.git目录】
所有文件,都首先在工作区新建,然后可以存入仓库(版本库),进行版本控制。
5.3 暂存区
暂存区也在 .git 目录内,工作区的文件进入仓库时,要先进入暂存区。
5.4 分支
版本控制,简单说,就是记录文件的诸多版本,分支就是这些版本的最终记录位置。
六、基本操作
6.1 查看仓库状态
执行 git status 可以看到工作区中文件的状态
未记录过的文件,是未跟踪状态
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%9F%A5%E7%9C%8B%E7%8A%B6%E6%80%811.jpg?t=181dbe79-e1cc-4fbb-a8f3-aefe6b807dec)
6.2 暂存文件
执行 git add . 将工作区中的文件全部存入暂存区
将工作区中的文件存入暂存区
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%9A%82%E5%AD%98%E6%96%87%E4%BB%B6.jpg?t=3acfa602-b498-453d-909e-d1f5018ffa82)
6.3 提交文件
执行 git commit -m "这里写提交的描述信息" 作用是将暂存区的文件存入分支,形成一个版本
提交文件,形成一个版本
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%8F%90%E4%BA%A4%E6%96%87%E4%BB%B6.jpg?t=3e1d4bcd-a7a7-4cf5-961b-b5e59e00dac6)
七、远程仓库
第5章中的仓库,其实是本地仓库。当多人协同开发时,每人都在自己的本地仓库维护版本。但很重要的一点是,多人之间需要共享代码、合并代码,此时就需要一个远程仓库。
7.1 远程仓库工作模式
远程仓库工作模式
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93.jpg?t=f5bb49c4-6c9c-4dca-936e-1ab19a58ab2e)
7.2 远程仓库选型
有很多远程仓库可以选择,比如 github(https://github.com/),码云(https://gitee.com/);此两种可以注册自己测试使用,但如果是商业项目,需要更多支持需要付费。公司内部也可以有自己构建的远程仓库(http://qianfeng.qfjava.cn:8087/users/sign_in)。
7.3 基本操作
每个开发人员,在面对远程仓库时,会面临的一些基本操作。
7.3.1 注册git服务器账号
在 码云 注册账号,并登录。进入公司后,很可能会使用公司自己搭建的git服务器,则账号向领导索要即可
登录后显示主页
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E7%A0%81%E4%BA%91%E7%99%BB%E5%BD%95.jpg?t=a8f4e1c2-ae0c-4619-9d27-2b9d3f331f84)
7.3.2 新建远程仓库
创建远程私有仓库-01
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%88%9B%E5%BB%BA%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%931.jpg?t=c4b7e2d5-40eb-4b44-97f5-a8c75f051e99)
创建远程私有仓库-02
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%88%9B%E5%BB%BA%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%932.jpg?t=52d1cce8-d3c8-4349-8e62-dc727d42cb46)
创建远程私有仓库-03
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%88%9B%E5%BB%BA%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%933.jpg?t=2a67049a-7ec4-4dcd-9653-29ae36a2c490)
7.3.3 本地关联远程仓库
本文档中选用仓库的 https协议的地址,将此地址关联到本地git中
如此后,本地即可用“origin” 代指远程仓库
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%85%B3%E8%81%94%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93.jpg?t=542d3a30-c466-4f7c-8b70-385064f5a8ac)
7.3.4 推送文件到远程仓库
将本地仓库中已经commit的内容push到远程仓库,以共享自己的代码。
push
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/push%E5%88%B0%E8%BF%9C%E7%A8%8B.jpg?t=2c8bd6b0-59d3-4f11-8db7-081e1cd288bb)
输入凭证,如此码云才能接受此次上传的内容
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/push%E5%88%B0%E8%BF%9C%E7%A8%8B_%E8%BE%93%E5%85%A5%E5%87%AD%E8%AF%81.jpg?t=83c6885f-f9ee-4b29-9ad3-6abfbf07fc56)
7.3.5 克隆远程仓库
如果仓库已经由别人创建完毕,我们需要其中的内容,则可以通过 git clone 将其复制到本地。
新建目录“repo2”,然后在其中执行 git clone
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/clone%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93.jpg?t=ea216719-9080-47ca-bdc7-908fba276061)
远程仓库,复制到本地,并自动初始化为一个本地仓库
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/clone%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%932.jpg?t=20254433-6882-4c0b-8354-842796437f08)
7.3.6 代码共享
多人协同开发时,写好代码的git push 上传到远程仓库;需要代码的 git pull 拉取代码即可。
有人再次将本地仓库内容,上传到了远程仓库
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/pull%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%931.jpg?t=f62e4d69-ba13-4ead-98be-dbbe233f5dfb)
重点:此时另一方如果想获得更新,则需要做一次拉取 git pull
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/pull%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%932.jpg?t=8daf95ab-e1e6-434e-b6f1-98e2a111e74d)
7.3.7 命令汇总
命令 | 描述 |
git remote add 标识名(master) 远程地址 | 本地关联远程仓库 |
git push 标识名 master | 将本地仓库内容上传到远程仓库 |
git pull 标识名 master | 从远程仓库下载内容到本地仓库 |
git clone 远程地址 | 将远程仓库复制到本地,并自动形成一个本地仓库 |
八、分支
8.1 分支简介
分支,是一个个版本最终存储的位置。分支,就是一条时间线,每次git commit形成一个个版本,一个个版本依次存储在分支的一个个提交点上。
分支由多个提交点组成,分支上会有一个指针,默认总是指向最新的提交点
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%88%86%E6%94%AF%E5%9B%BE%E4%BE%8B1.jpg?t=e0a5d540-566e-460f-9632-9fb37365db8d)
8.2 分支操作
8.2.1 查看分支
查看当前仓库的分支 git branch仓库中默认只有 master 分支执行git commit时,默认是在master分支上保存版本。
默认只有master分支
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%9F%A5%E7%9C%8B%E5%88%86%E6%94%AF-master.jpg?t=9261afff-878d-4930-a826-c0272e36c8a7)
8.2.2 创建分支
在商业项目开发过程中,我们不会轻易的在master分支上做操作。我们会新建一个开发用的分支,在此分支上做版本的记录。当代码确实没有问题时,才会将开发分支上成熟的代码版本添加到master分支上。保证开发过程中,可以及时记录版本,又保证master分支上每个提交点都是稳健版本。
创建分支
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF.jpg?t=cbd56fef-c316-4eb7-a4eb-537d9480cb38)
8.2.3 切换分支
默认情况下,当前使用的分支是 master分支可以切换到 dev分支,则后续的git commit 便会在dev分支上新建版本(提交点)
切换分支
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%88%87%E6%8D%A2%E5%88%86%E6%94%AF.jpg?t=056938b3-9143-483f-ab8a-7d40376ca481)
再次查看分支情况
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%9F%A5%E7%9C%8B%E5%88%86%E6%94%AF.jpg?t=91fb6ab8-d095-4f3a-a670-7d651eab5efa)
8.3 新建分支细节
新建分支时,新分支,默认有哪些内容?分支中包含了哪些次提交?
8.3.1 新分支初始内容
每个分支都有一个指针,新建一个分支,首先是新建一个指针。而且新分支的指针会和当前分支指向同一个提交点。新分支包含的提交点就是从第一个提交点到分支指针指向的提交点。
每个分支都有一个指针,新建一个分支,首先是新建一个指针
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF%E7%BB%86%E8%8A%821.jpg?t=8c6082ae-1b95-4e0d-8af9-961c295585e1)
8.3.2 多分支走向
在master分支和新分支,分别进行 git add 和 git commit分支情况如下图:
master分支未动,在dev分支增加一次commit
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF%E7%BB%86%E8%8A%822.jpg?t=a29fea24-60dd-4379-8e2a-a7dc27e7593f)
master分支增加一个commit,dev分支再增加一个commit
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF%E7%BB%86%E8%8A%823.jpg?t=d85eb5da-0e25-46e2-a3e9-1fbb0b3fb15e)
8.3.3 分支提交日志
查看分支的提交日志,进而看到分支中提交点的详细情况。
提交情况如下
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%8F%90%E4%BA%A4%E6%97%A5%E5%BF%97.jpg?t=c72a62e7-ba30-4318-b381-7f192251f33f)
查看当前分支的提交日志
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%8F%90%E4%BA%A4%E6%97%A5%E5%BF%972.jpg?t=8dd12586-2a8a-4e3a-8397-0882bf079ec2)
8.4 分支合并
两个分支内容的合并
git merge 分支a 合并分支a
合并的方式有两种:快速合并 和 三方合并。
8.4.1 快速合并
如果分支A当前的修改,是完全基于分支B的修改而来,则B分支合并A分支,就是移动指针即可。
合并前分支状态
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF%E7%BB%86%E8%8A%822.jpg?t=dbbc8625-063e-460e-9605-11a42ce25bbe)
快速合并效果(master 合并 dev)
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%BF%AB%E9%80%9F%E5%88%86%E6%94%AF%E5%90%88%E5%B9%B6.jpg?t=b7ae014a-486d-4e2d-aa28-d3e6edb8a1a9)
8.4.2 三方合并
在不具备快速合并的条件下,会采用三方合并。
合并前,分支状态
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF%E7%BB%86%E8%8A%823.jpg?t=bc1e6111-b00d-45a9-bd42-979e5af9b231)
三方合并,将和的更改都累加在上,形成新的提交点
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E4%B8%89%E6%96%B9%E5%90%88%E5%B9%B6.jpg?t=a1983b85-9fd4-4355-9305-ebf68921747d)
8.4.3 合并冲突
两个分支进行合并,但它们含有对同一个文件的修改,则在合并时出现冲突,git无法决断该保留改文件哪个分支的修改。
8.4.3.1 冲突演示
场景模拟如下:
master分支修改hig.txt文件
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%86%B2%E7%AA%811.jpg?t=4b00d28b-b9e8-4c4e-bc04-e33f5d85b6a1)
dev分支修改hig.txt
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%86%B2%E7%AA%812.jpg?t=40ae5908-62c4-4a3b-807f-db67ca5e3664)
在master分支 合并 dev分支
合并dev分支
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%86%B2%E7%AA%813.jpg?t=22d404ca-5a96-4e4d-b4b9-1cb7819a7d12)
此时,打开hig.txt 文件:
冲突后,git会将两个分支的内容都展示在文件中
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%86%B2%E7%AA%814.jpg?t=889b29fb-fa3e-4184-a5da-d2b3cbccfe5c)
8.4.3.2 冲突解决
出现冲突后,如要由两个开发人员当面协商,该如何取舍,为冲突文件定义最终内容。解决方案:
- 保留某一方的,删除另一方的
- 保留双方的
- 但无论如何,要记得删除 <<<< ==== >>>> 这些
- 本质是两人协商为冲突的内容,定制出合理的内容。
根据协商,再次编辑文件
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%86%B2%E7%AA%815.jpg?t=1e6e023e-19e8-4b29-aeb5-763ac28d8da5)
提交 再次编辑后的文件
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%86%B2%E7%AA%816.jpg?t=85aaa2ca-2409-48ed-8a26-c2baaa8cf511)
九、Idea关联Git
9.1 关联Git
File > Settings 关联过程是自动的
此处关联是Idea可以自动完成的
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E5%85%B3%E8%81%94git.jpg?t=d9c14db0-8815-4320-8792-1d1833253aaf)
9.2 创建仓库
新建项目后,将项目目录创建为git仓库注意: 要在建仓库前,设置忽略文件 ".gitignore"作用:被忽略的文件会被版本记录忽略,版本中不包含它们。范围:不需要和其他开发共享的文件,具体见下图。
创建仓库前,先添加忽略文件
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E5%88%9B%E5%BB%BA%E4%BB%93%E5%BA%930.jpg?t=82c569f3-3bf6-4a8a-bf64-38d306b15be9)
将项目目录初始化为一个仓库
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E5%88%9B%E5%BB%BA%E4%BB%93%E5%BA%931.jpg?t=68a940fe-5149-49ba-b9bd-826f2b84a532)
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E5%88%9B%E5%BB%BA%E4%BB%93%E5%BA%932.jpg?t=e5c0912a-353d-41a7-9a08-a3c8486a5a93)
9.3 提交-commit
创建好仓库后,做第一次提交。
选择提交菜单
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-commit.jpg?t=b25376bc-2c21-4830-b601-6247c2c4a3a4)
选择提交文件,定义提交信息
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-commit2.jpg?t=b022b186-de7a-463a-b562-276070af9519)
之后会有些友好提示,可以忽略,点击即可
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-commit3.jpg?t=9b05900e-88af-4391-8599-eb3c439c99d4)
9.4 创建分支
新建开发分支
点击右下角链接,即可
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF.jpg?t=442f6107-b211-4389-ba89-7493aef4849e)
新建分支
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF2.jpg?t=3f020821-6d1b-42d7-bddb-855a2172dd42)
查看当前分支
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E6%96%B0%E5%BB%BA%E5%88%86%E6%94%AF3.jpg?t=95b5b373-2eed-4007-b80b-881fca2e92c3)
9.5 上传到远程仓库(push)
请首先参照第7章,创建一个远程仓库。要求是裸库,且建议库名和项目名同名。
选择菜单
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-push.jpg?t=f000dd02-942e-409e-aeea-5cb040fb9db3)
定义远程仓库地址
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-push3.jpg?t=06d650f0-d145-44bf-8510-329d67d54d35)
执行,push操作
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-push4.jpg?t=963ecdad-24cb-43cc-9c0d-466090b844a2)
push成功后 ,弹窗提示
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-push5.jpg?t=59534b1e-cb06-4023-b961-e3a9e02e3828)
9.6 复制到本地仓库(clone)
如果有建好的远程仓库,比如公司内已经在用的仓库,或者github,码云上的一些公开仓库,可以将远程仓库的项目复制到本地使用。
点击克隆菜单
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-clone1.jpg?t=8969bdce-c899-46a9-b7c4-59202bc6ca32)
输入如远程仓库地址
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-clone2.jpg?t=73bd4832-28e2-4f75-8a5e-cbee0d51bf35)
打开项目
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-clone3.jpg?t=1563c080-1de6-47f3-9fce-32453949856c)
打开项目,选项
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-clone4.jpg?t=69b79659-bc56-4367-b4d2-4aa5665d8d51)
9.7 更新本地项目
如果远程仓库有更新,则你的本地项目也需要一起更新。
选择pull菜单
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-pull1.jpg?t=f0d4c75f-eecb-4479-97af-acf705e75936)
执行 pull操作
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-pull2.jpg?t=fac7004e-4d72-415e-b2ae-23e20b17f1f6)
更新日志显示
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-pull3.jpg?t=698f881e-2969-4a56-8d90-3724f5121798)
9.8 冲突解决
合并分支时,如果出现冲突,则需要解决冲突。
冲突出现,弹窗中可以选择如下
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E5%86%B2%E7%AA%81.jpg?t=8e26226f-b3ad-4d8a-8bf0-75c12ec671cb)
也可以直接修改冲突文件,然后commit即可
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/idea-%E5%86%B2%E7%AA%812.jpg?t=b365292a-6e35-4403-bd58-7a48e04e16ee)
十、多人协同开发
多人开发协同,git操作
10.1 项目管理员( 项目经理 )
1> 由管理员负责创建一个远程库,初始的库中什么也没有,为裸库。库的名称建议和项目同名
2> 管理员会在idea中创建一个初始项目,其中包含.gitignore文件。 并在项目根目录下 建立本地库。并建立 dev分支。
3> 管理员将本地库上传到远程库
4> 将其他开发人员拉入远程库的 开发成员列表中 ,使得其他开发人员可以访问该远程库。流程如下:
点击添加成员
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%B7%BB%E5%8A%A0%E5%BC%80%E5%8F%91%E6%88%90%E5%91%98.jpg?t=18e5588e-7673-4f70-a0a3-dccafd54bb61)
选择直接添加
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%B7%BB%E5%8A%A0%E5%BC%80%E5%8F%91%E6%88%90%E5%91%982.jpg?t=e3c68508-12cb-496e-a992-ffa109781e77)
提交
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%B7%BB%E5%8A%A0%E5%BC%80%E5%8F%91%E6%88%90%E5%91%983.jpg?t=8e32c118-0382-4665-9791-f4ab04cc8a73)
查看已添加的开发成员
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E6%B7%BB%E5%8A%A0%E5%BC%80%E5%8F%91%E6%88%90%E5%91%984.jpg?t=f9d3165b-3a8b-4249-9fb5-04c22eec5e05)
5> master分支设置为 protected分支,只有管理员有权限将代码合并到其中。dev分支设置为 常规分支所有开发人员 都可以其中合并代码
进入分支设置
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E4%BF%9D%E6%8A%A4%E5%88%86%E6%94%AF1.jpg?t=56e87655-3299-4b27-b717-7b5d15a96561)
设置保护分支,让master分支不能被随更改
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E4%BF%9D%E6%8A%A4%E5%88%86%E6%94%AF2.jpg?t=20efb5f4-f9cc-4afe-aab2-7044e117d3f9)
10.2 开发人员
初始化:在idea中clone 远程库,获得项目。会建立本地库后续的开发中,都要在dev分支上进行。开发完一个功能并测试通过后就commit 提交到本地的dev分支中,然后 上传(push)到远程dev分支中。需要更新项目内容时,通过 pull 从远程仓库拉取内容。注意:多人协同时,每次在 push 到远程库前,都先做一次pull,一来是把远程最新内容合并到本地,二来是核实本地内容是否和远程内容有冲突。后续的开发,会接到一个个的功能任务,往复操作 2>、3>、4> 而已。
十一、经典问题
在使用https协议做push时,如果曾经使用过码云,但密码有过改动,此时会报错
使用https协议报错
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%9D%911.jpg?t=a46b4b16-0157-41b0-a3ec-91c581e34bf2)
解决方案: 控制面板 》 凭据管理器 》 删除对应凭证,再次使用时会提示重新输入密码。
删除之前的码云凭证,然后重新push即可
![notion image](https://gulimallcativen.oss-cn-shenzhen.aliyuncs.com/img/%E5%9D%912.jpg?t=8ae64247-0da8-431d-8f61-2017213e8021)
- 作者:IT小舟
- 链接:https://codegym.top/article/git
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章