分支理解
master分支是项目在创建时候的默认分支,除此之外,它并没有更多的含义。
剩下的 “开发分支”,“灰度分支”, “预发布分支”, “需求分支”,“测试分支” 都是根据项目和需求约定的。它们本质上只是一个分支而已。
分支在项目中的应用
1、首先,我们创建了一个项目:
这是我局域网搭建的gitlab,我们就以这个项目为例。
2、项目的基本流程:
克隆项目到本地
Cloning into 'myproject'...
warning: redirecting to http://10.2.16.183/zhiheng/myproject.git/
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
切换到项目:
> cd myproject
查看当前状态
> git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
a.py
nothing added to commit but untracked files present (use "git add" to track)
提交代码
> git add a.py
> git commit -m "first file"
> git push origin master
3、分支的使用
为什么要使用分支?
1、你在开发项目里面一个很大的模块,这个模块需要连续开发一个月,你可以选择一个月提交一次,但一个月的开发代码都存在你的本地电脑是很危险的。万一电脑丢失,代码被误删,损失很大!
2、你们团队的项目有十几个人在维护,每天会有N多次的提交,一旦你拉取和提交的间隙,被别人提交了代码,当你在提交的时候别人就需要解决冲突。每次解决和提交冲突是很浪费时间的。
分支的使用
查看所有分支&#x