1.目前我们怎么部署项目的?
运维,公司对语言的选择,千变万化
v1 陌陌APP只支持聊天功能
1. 拿到源代码
怎么拿?
公司会部署代码仓库,进行源代码管理(github,gitlab,gitee码云)
开发会吧代码传到这个仓库里
运维,测试去下载这个源码
php代码写的
2. 准备机器环境(测试服务器,线上服务器)
为什么要有测试环境(公司内部的,内侧环境,社会用户是访问不了)?
软件代码必然会有bug,需要层层测试通过后,确认bug很少了,可以达到上线标准了
【vip充值功能,才能查看小姐姐的联系方式,bug,没做好用户的权限校验,不充钱也能看】
软件达到的上线标准,
才会进入到生产服务器的部署(ip,域名,是面向社会用户)
linux机器 + mysql + php-fpm + nginx
3. 启动
参考你理解的wordpress,就是部署php源码程序的流程,到这听懂111111
4. 项目开始运行再线上,可能会出现N种未知的错误,出了问题,得公司的技术团队,支持解决
拿钱干活,日常到底要干啥,
- 运维,主要就是软件发版时忙一点,准备上线的环境
- 日常的项目运行中,对服务器的维护,通过搭建监控系统等,确保系统的可用性
听懂111111
黑客攻击,发送了大量的请求,无用的请求
线上代码运行,代码是当用户访问到,基于某个url,请求,nginx代理转发给了某个模块
(你不点登录,会触发哪个登录代码吗?登录的代码,是有bug的,但是你运行项目时,没执行该功能代码,因此项目时可以运行起来,但是不代表项目时正确)
因此公司才需要招测试工程师去一个个功能的点击,最终确认该软件是没问题的
基于这个理念,网站上线了,有某个优惠券的功能,开始发现不了有bug,但是再用户(也可以作为一个测试的角色去理解),代码触发执行,发生了bug,发现如优惠券,无法用的bug,F12抓请求,发现请求是500了,因此公司团队的,运维,开发,介入,修复 bug,重启,重新上线。
这段概念,理解666666
5. 后期的项目更新,网站加了新功能,陌陌这个公司,APP,仅仅是聊天交友,得上线直播板块功能
- 软件发版更新
1. 开发,推送v2版本的代码,到代码仓库
2. 下载代码,手动,或者shell脚本,将代码上传至目标服务器,干掉旧进程,替换源代码,重启新进程,确保软件更新
3. 测试访问是否正常。
看懂333333
6. 疑问?为什么要学这个cicd章节?
如果你负责的业务太多,陌陌玩过把(app的业务功能),N个功能,N个板块,N套源代码,运行了N个进程,需要运维去维护。
运维,可能要维护多个系统,上述流程,都需要你去,上线准备环境,准备机器,安装软件,改配置,重启,更新,发版,等。、。。。。。
php 启动,部署的方式都不一样
python 启动,部署的方式都不一样
java 启动,部署的方式都不一样
2.学习完毕cicd之后如何部署?按如下思路来。
必须得至少通过shell脚本完成,能实现环境的批量化,可复制操作。 111111
还有就是更新,上线等一个流水线的操作,手动就别想了,那么人家陌陌公司,中大型公司,业务量大,就必须要求技术团队的能力要跟得上业务,
要求,运维,都得懂些开发的知识,打造devsop,运维开发流水线团队。
部署私有代码仓库,构建工具,实现,鼠标一点,就更新
运维能实现,前期把构建项目的环境准备好,后期,连鼠标都可以扔了,不用点。
开发推送代码,运维搭建的这个流水线,自动将代码更新到测试,线上环境,。
运维只需要躺着喝咖啡,看日志就行。
这套系统学不学。
学1111111
是一个小公司,5个左右的业务,招1,2普通运维,手工维护也差不多能行
那么,本阶段的课程,正式开始。休息片刻,理解下业务层面的知识。
devops运维工程师进阶之路
2.什么是版本控制系统
1.当公司的服务器架构越来越复杂,需要频繁的发布新配置文件,以及新代码;如何确保多个版本的存在?
引入版本控制系统,的工作中应用
微信的APP,软件发布,源代码的版本管理
v1 版本支持 "语音功能"
v2 版本 "支持语音转文字功能"
v3 版本,"支持视频聊天功能"
运维的配置文件管理
v1 nginx.conf "支持首页www的虚拟主机配置"
v2 nginx.conf "支持三个业务的虚拟主机配置,本次添加了3个server{}配置"
1111
具体版本控制系统,能实现什么效果 ,接着看
2.但是如果机器部署数量较多,发布的效率必然很低;(自动化构建系统)
devops,产品经理需要去定义的,开发模式。
软件开发理论。开发运维测试,一套流水线
3.并且如果代码没有经过测试环境,预生产环境层层测试,最终才到生产环境,不经过测试的部署,会导致很严重的bug,因此必须要进行一定的代码测试。(再运维构建系统中,还支持对代码的扫描,检测,bug检测,如漏洞检测。)
1. 开发提交了一堆代码 *.php,提交到代码仓库
2. 运维部署的构建系统,下载代码,自动化测试,扫描代码(大多数bug,漏洞全扫出来,只有通过了代码的质量检查之后,下一步的动作,才进入,部署到具体的生产服务器上
因此,再互联网公司中的开发,模式,就是 开发 > 测试 >运维,一套流水线,确保软件的高质量发布,切频繁发布,频繁迭代更新。
这就是devops文化,
因此从devops部署理念来看,任何一家单位都必须实现CICD(持续集成、持续交付)的理念,实现自动化代码集成、自动化代码部署。
如何落地,打造一个devops开发团队呢?
让开发,和运维再同一个组,运维也得懂开发的一些知识,部署软件更新流水线,能实现,快捷的软件发布,软件更新,软件测试。
学会了这套系统的运维,就是devops运维工程师了。、
目前主流的解决方案,学习的技术就是
git 代码版本控制系统
jenkins 代码构建系统
gitlab 私有代码仓库
sonarqube 代码扫描工具
这套理念,大致听懂6666
3.你以后的成长之路是如何?
1.今天的学习重点
1. 是理论,理解devops高级运维工程,要懂得架构体系知识
2. 学习git工具
4.开始学习自动化构建系统组件之一,git
为什么要版本记录?不用行吗?
当你学了git工具之后,对linux的源码管理,配置文件管理
可以用在你自己的windows机器上,
word文档版本管理
execel文档
markdown笔记,版本管理,都可以通过git实现多个版本的管理,
历史版本回退。
什么是版本控制系统
什么是cicd,俩名词
ci ,持续集成
什么是ci/cd
在源代码,持续合并多次的过程中,每次合并,到master主干线,都要
具体进行源码的版本管理,有哪些软件呢?
- svn老旧,非互联网公司可能用,矿场,机场,传统行业电子制造业,软件系统
- 源码管理
- git工具,所有互联网公司必备(linux的老父亲,林纳斯托瓦兹开发的,开发git工具)
- linux内核源码,
什么是svn,集中式的版本控制系统
不好用
分布式版本控制系统git的强大
git工具,基本是开发工程师去写代码,进行的多版本维护的使用
运维,可以基于git实现对自己配置文件的多版本管理
运维主要就是学习
如何对一个git代码仓库,进行命令操作
查看版本日志
版本提交
版本回退
这些操作
12.10继续
休息会
课间,思考下,理解理解git的图
这个git的架构,还是有一定的理解难度的
等学完了git的实际操作,分支,远程仓库后,即可理解
5.git全流程
以学习git工具为主,实践
linux安装
yum install git -y
[root@web-7 ~/git-learn]#git --version
git version 1.8.3.1
身份设置
一般用如下命令,设置身份即可
# 给git设置配置信息 --global 参数,身份信息,会写入 ~/.gitconfig
git config --global user.name "wenjie"
git config --global user.email "wenjie01@163.com"
# 开启git命令的颜色支持
git config --global color.ui true
查看配置文件
cat ~/.gitconfig
查看当前机器的git身份配置信息
[root@web-7 ~/git-learn]#cat ~/.gitconfig
[user]
name = wenjie
email = wenjie01@163.com
[color]
ui = true
[root@web-7 ~/git-learn]#git config --list
user.name=wenjie
user.email=wenjie01@163.com
color.ui=true
看懂刷 222222
git三个使用场景
git能够记录,源代码目录中,所有文件的状态,这个记录的数据,都在 .git这个隐藏文件夹中
使用git命令,有3个场景
玩法1,本地已经写好了代码,需要用git去管理
git的使用流程套路
1. git init . 初始化本地仓库
2. 写代码,如 hello.sh
3. 通过git add . 进行本地文件追踪管理,文件信息被记录到 暂存区
4. git commit -m '注释' ,将暂存区的数据,提交到local repo 本地仓库,进行第一个版本的记录
[root@web-7 ~/git-learn/my_shell]#pwd
/root/git-learn/my_shell
[root@web-7 ~/git-learn/my_shell]#
[root@web-7 ~/git-learn/my_shell]#ls
hello.sh
[root@web-7 ~/git-learn/my_shell]#
[root@web-7 ~/git-learn/my_shell]#
[root@web-7 ~/git-learn/my_shell]#ls -a
. .. hello.sh
没有被git进行管理
使用git进行,从0 到1管理
1. 初始化生成 .git文件夹
[root@web-7 ~/git-learn/my_shell]#git init .
初始化了一个空的git仓库 再 /root/git-learn/my_shell/.git/
Initialized empty Git repository in /root/git-learn/my_shell/.git/
查看这个.git本地仓库的文件夹,有什么内容
[root@web-7 ~/git-learn/my_shell]#ls .git
branches config description HEAD hooks info objects refs
这个时候,/root/git-learn/my_shell
该文件夹,就被git管理了
再这个目录下对文件的修改类操作,就会被git进行记录了
命令,查看git工作区的状态
[root@web-7 ~/git-learn/my_shell]#git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# hello.sh
nothing added to commit but untracked files present (use "git add" to track)
追踪文件属性
[root@web-7 ~/git-learn/my_shell]#git add hello.sh
[root@web-7 ~/git-learn/my_shell]#
[root@web-7 ~/git-learn/my_shell]#
[root@web-7 ~/git-learn/my_shell]#
[root@web-7 ~/git-learn/my_shell]#git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: hello.sh
#
提交版本了,提交第一个版本
[root@web-7 ~/git-learn/my_shell]#git commit -m 'v1 第一次提交'
[master (root-commit) 67d8f28] v1 第一次提交
1 file changed, 1 insertion(+)
create mode 100644 hello.sh
此时再用git status查看工作区的状态是如何
此时工作区就很干净了,需要提交的代码,没了
[root@web-7 ~/git-learn/my_shell]#git status
# On branch master
nothing to commit, working directory clean
图解git玩法流程
从零新建git本地仓库,编写代码
克隆远程仓库中的代码
图解git工作流
day77开始=================
昨日回顾
gitignore文件忽略文件不用被git管理
图解多人协作写代码,分布式源码版本控制,与运维的联系
============================
6.git实战流程
从零初始化git本地仓库
git init /my_code/
查看本地仓库的状态
[root@tomcat-10 /my_code]#echo "123123123" > 打起精神来.log
[root@tomcat-10 /my_code]#
[root@tomcat-10 /my_code]#
[root@tomcat-10 /my_code]#
[root@tomcat-10 /my_code]#git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# "\346\211\223\350\265\267\347\262\276\347\245\236\346\235\245.log"
nothing added to commit but untracked files present (use "git add" to track)
加入暂存区
[root@tomcat-10 /my_code]#git add 打起精神来.log
[root@tomcat-10 /my_code]#
[root@tomcat-10 /my_code]#
[root@tomcat-10 /my_code]#git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "\346\211\223\350\265\267\347\262\276\347\245\236\346\235\245.log"
#
[root@tomcat-10 /my_code]#
从暂存区移除文件
本地仓库的细节知识
2个场景
场景1,本地仓库,以及有了第一个版本
[root@tomcat-10 /my_shell]#git add hehehehe.sh
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: hehehehe.sh
#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]## 看懂11111
[root@tomcat-10 /my_shell]#git log
commit 3b4420b805b297239d9b3adc8c8605e593cab5d9
Author: pyyu <yc_uuu@163.com>
Date: Fri Jul 15 18:56:09 2022 +0800
那我走?
场景2,本次仓库是空的,还没有任何版本
[root@tomcat-10 /my_shell]## 2个选择,1是提交一个版本 2是撤销暂存区的记录 ,看懂22222
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git log
fatal: bad default revision 'HEAD'
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: xixixixix.sh
#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git rm --cached xixixixix.sh
rm 'xixixixix.sh'
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# xixixixix.sh
nothing added to commit but untracked files present (use "git add" to track)
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]## git add git commit
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]## 再空本地仓库中的,撤销动作 git rm --cached file 看懂 11111
重新跟踪、提交文件
基于撤销的动作基础上,再次版本提交
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# hehehehe.sh
nothing added to commit but untracked files present (use "git add" to track)
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git add hehehehe.sh
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git commit -m 'heheheh 那我走?'
[master 0c750ff] heheheh 那我走?
1 file changed, 1 insertion(+)
create mode 100644 hehehehe.sh
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git status
# On branch master
nothing to commit, working directory clean
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git log
commit 0c750ff9db54f7d7a1397c413753236f3f9dfe67
Author: pyyu <yc_uuu@163.com>
Date: Fri Jul 15 19:03:27 2022 +0800
heheheh 那我走?
commit 3b4420b805b297239d9b3adc8c8605e593cab5d9
Author: pyyu <yc_uuu@163.com>
Date: Fri Jul 15 18:56:09 2022 +0800
那我走?
gi t如何查看文件状态
git status
基于git的文件重命名
记住如下用法
如果你要在某个版本仓库下,修改文件的名字,如何改(修改,删除,都会对文件的元属性进行修改)
git mv
git rm
俩命名
# 需求,记住如下正确改名的玩法即可
1. 原本的数据是
[root@tomcat-10 /my_shell]#ls
hehehehe.sh xixixixix.sh
这俩文件都被提交为了一个版本记录,此时暂存区是空了
2. 需求是 修改xixixixix.sh 改为 java后缀
正确玩法应该是
git mv xixixixix.sh xixixixi.java
git commit -m '于超 重命名了 xixixi.sh 为xixix.java'
3
基于git的删除文件
记住,再git本地仓库中,只要是被git管理的,记录为某个版本的文件,就不能直接
rm去删
先记住正确删除的玩法
git rm去删
[root@tomcat-10 /my_shell]#git rm *.log
rm '1.log'
rm '2.log'
rm '3.log'
rm '4.log'
rm '5.log'
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#
[root@tomcat-10 /my_shell]#git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: 1.log
# deleted: 2.log
# deleted: 3.log
# deleted: 4.log
# deleted: 5.log
再提交一个存档,版本
理解git为什么要提交版本
1.30继续
多动手瞧瞧
====下午继续====================
提交暂存区数据到local repo
多次提交版本的玩法
提交v1版本
提交v2版本
提交v3版本
[root@tomcat-10 ~/springboot-bucket]#git log --oneline -4
953662c v3
e3e79e8 v2
22d5088 v1
c45df36 开发了hello.py
###
git版本历史
git log
通过git log 查看当前的本地git仓库,所有的commit 提交记录
git版本回退
git对文件的状态提交了N个版本,(就好比你的vmware的快照)
回退上一个版本,回到v2
[root@tomcat-10 ~/springboot-bucket]#git reset --hard HEAD^
HEAD is now at e3e79e8 v2
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git log --oneline -4
e3e79e8 v2
22d5088 v1
c45df36 开发了hello.py
8f146f0 !1 修复 AOP的案例,调用/doError时异常不打印 Merge pull request !1 from 海王星Ivan/master
没创建一个文件,就提交了一个记录
v2 > v3 (v3.sh)
v3 版本回退到了 v2 (v2.sh 还没创建v3.sh的状态)
再回到第一个v1
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git reset --hard HEAD^
HEAD is now at 22d5088 v1
想让我们自己瞎搞的提交记录,全部消失(不显示,回退)
[root@tomcat-10 ~/springboot-bucket]#git reset --hard 8f146f0
HEAD is now at 8f146f0 !1 修复 AOP的案例,调用/doError时异常不打印
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#ls
LICENSE springboot-echarts springboot-rabbitmq-rpc springboot-starter
README.md springboot-hibernate springboot-redis springboot-swagger2
springboot-aop springboot-jwt springboot-restful springboot-thymeleaf
springboot-async springboot-mongodb springboot-resttemplate springboot-transaction
springboot-batch springboot-multisource springboot-schedule springboot-websocket
springboot-cache springboot-mybatis springboot-shiro
springboot-cxf springboot-rabbitmq springboot-socketio
[root@tomcat-10 ~/springboot-bucket]## 我们自己的提交记录都没了,因为版本回退到,自带的某一个版本了
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]##看懂111
###
###
穿梭未来(如何再git所有的版本中,来回切换)
回到了2018年
如何再回去?回到今天2022年提交的 v1 v2 v3 找回来。
版本回退的核心点,找到commit id把
git log只能看到当前HEAD指向的最新的记录,以及历史的记录
通过git reflog查看到你对这个本地仓库做了哪些操作
1.git分支
在前面我们基本了解Git的使用方法,这一节我们看下GIt重要概念【分支】
背景
例如于超老师在开发一个同性交友网站,刚写到登录功能,代码还没写完,今天先睡觉了,所以就commit提交到本地仓库了。
假如这会另一个程序员张三不知道,还直接对这个代码继续开发,这就乱套了。
讲道理,应该这么玩:
1. 分别给于超老师添加一个分支 yuchao,张三一个分支 zhangsan
2. 这俩人基于自己的分支环境去写代码,进行版本提交,却能互不影响
3. 最后将这2人的代码进行合并即可(需要考虑可能存在冲突,手动解决)
1.1 分支命令实践
如下操作,我们是用本地仓库作为练习,创建分支,合并分支到master
切换分支
是在一个机器本地上操作
但是,同理玩法下,这个仓库,应该是由远程仓库提供,如在码云中的代码仓库
提供如master分支
zhangsan分支 张三推代码
bob 分支 鲍勃推代码
最终他俩的代码合并到master
运维直接下载master的代码,到linux服务器上,为最终线上源码。
默认版本仓库只有一个分支,master
git branch
直接看到当前版本仓库 有几个分支
以及有星星的哪个分支,就是你再用的
[root@tomcat-10 ~/springboot-bucket]#git branch
* master
创建分支
1. 命令先创建好分支,再切换过去
[root@tomcat-10 ~/springboot-bucket]#git branch liangliang
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git branch
liangliang
* master
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git branch wenjie
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git branch
liangliang
* master
wenjie
[root@tomcat-10 ~/springboot-bucket]#git checkout wenjie
Switched to branch 'wenjie'
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git branch
liangliang
master
* wenjie
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]## 看懂分支的创建,切换,以及查看 1111
[root@tomcat-10 ~/springboot-bucket]#
2. 直接创建,并且立即切换分支
[root@tomcat-10 ~/springboot-bucket]#git checkout -b yuchao
Switched to a new branch 'yuchao'
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git branch
liangliang
master
wenjie
* yuchao
切换分支
wenjie分支下写代码
这里就是公司里的多个程序员,如何开发同一套系统的流程了。
# 基于wenjie分支,创建文杰自己的代码,提交版本(再这个分支下的,版本记录,属于wenjie)
# 写代码、追踪、提交记录
切换到liangliang分支看看
切换master分支
敲黑板,重点
master和其他分支一样,就是个普通分支,没什么特点
只不过凑巧,它是默认的分支而已
想看到wenjie分支的代码,还必须得合并版本记录
看懂6666
你此时只有切到wenjie分支,才能看到代码文件
合并分支(合并文杰写代码,到master上来)
master作为约定俗成的默认分支,代码都合并到它这里即可。
合并wenjie分支的代码到master主干线上来
分支冲突
这里是新添加了一个文件,合并数据还好,如果是同一个文件,且同一行数据的修改,岂不是GG?
让分支提交的代码版本记录
和另外一个分支master也生成同一个文件,修改同一行数据
分支合并,冲突
1.再创建一个分支,liangliang,搞破坏,且提交代码到版本仓库
[root@tomcat-10 ~/springboot-bucket]#git log -2
commit 24a0a791ace3fd40b55428aded7488eafe0ee6df
Author: pyyu <yc_uuu@163.com>
Date: Fri Jul 15 23:20:58 2022 +0800
liangliang 提交了 sh文件
commit 953662cc4dd0c2f9807fb4a1256524af611712e9
Author: pyyu <yc_uuu@163.com>
Date: Fri Jul 15 22:01:46 2022 +0800
v3
2.切换回master分支,别合并,先修改同一个文件,注意提交到版本仓库
合并是指,版本记录的合并
3.试试这回合并代码呢?master和zhangsan修改了同一行数据
4.手工解决冲突即可
1.2 删除分支
开发完毕后,无用的分支都删掉即可
[root@tomcat-10 ~/springboot-bucket]#git branch
liangliang
* master
wenjie
yuchao
[root@tomcat-10 ~/springboot-bucket]#git branch -d liangliang
Deleted branch liangliang (was 24a0a79).
[root@tomcat-10 ~/springboot-bucket]#git branch -d wenjie
Deleted branch wenjie (was 1e07902).
[root@tomcat-10 ~/springboot-bucket]#git branch -d yuchao
Deleted branch yuchao (was 953662c).
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git branch
* master
[root@tomcat-10 ~/springboot-bucket]#
这是再本地仓库中的分支管理玩法
1.3 查看远程仓库,码云,的分支玩法
再你对git的分支命令操作,理解之后,点点点,就很小儿科了。
1.创建远程仓库(git init )
2.git标签
2.1 为啥用git标签功能
2.2 tag标签实践
3.git远程仓库
3.1 github
3.2 码云Gitee
# git remote add 添加一个远程仓库的别名 origin ,具体地址 https://gitee.com/yuco/linux0224.git
听懂22222222222
检查 当前本地仓库的,远程仓库配置
[root@tomcat-10 ~/springboot-bucket]#git remote -v
origin https://gitee.com/yidao620/springboot-bucket.git (fetch)
origin https://gitee.com/yidao620/springboot-bucket.git (push)
删除该记录
[root@tomcat-10 ~/springboot-bucket]#git remote remove origin
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git remote -v
关联你自己仓库,目前采用的是https协议,需要账户密码验证
git remote add origin https://gitee.com/yuco/linux0224.git
# git push 把本地仓库的数据,推送到origin远程仓库,推送到master分支中
git push -u origin "master"
[root@tomcat-10 ~/springboot-bucket]#git push -u origin "master"
Username for 'https://gitee.com': 877348180@qq.com
Password for 'https://877348180@qq.com@gitee.com':
Counting objects: 2800, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1155/1155), done.
Writing objects: 100% (2800/2800), 2.20 MiB | 640.00 KiB/s, done.
Total 2800 (delta 1062), reused 2771 (delta 1051)
remote: Resolving deltas: 100% (1062/1062), done.
remote: Powered by GITEE.COM [GNK-6.3]
To https://gitee.com/yuco/linux0224.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
[root@tomcat-10 ~/springboot-bucket]#
# 第二个玩法,基于sshkey的验证
# 结合者,本地写代码,推送到远程管理
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git log -2
commit 72c4941ea1ae99968276314ec09a9b752bf1b456
Author: pyyu <yc_uuu@163.com>
Date: Fri Jul 15 23:50:12 2022 +0800
鸡汤来了
commit 7d33b7e42f3a59bec687e34748eafdd557195294
Merge: 789ed99 24a0a79
Author: pyyu <yc_uuu@163.com>
Date: Fri Jul 15 23:31:07 2022 +0800
master修复了分支冲突 liangliang.sh
[root@tomcat-10 ~/springboot-bucket]#
# 修改为git协议
[root@tomcat-10 ~/springboot-bucket]#git remote -v
origin https://gitee.com/yuco/linux0224.git (fetch)
origin https://gitee.com/yuco/linux0224.git (push)
[root@tomcat-10 ~/springboot-bucket]#git remote remove origin
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git remote -v
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]##11111
# 修改为,git协议
git remote add origin git@gitee.com:yuco/linux0224.git
[root@tomcat-10 ~/springboot-bucket]#git remote add origin git@gitee.com:yuco/linux0224.git
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#
[root@tomcat-10 ~/springboot-bucket]#git remote -v
origin git@gitee.com:yuco/linux0224.git (fetch)
origin git@gitee.com:yuco/linux0224.git (push)
# 推送试试
# 还得去码云中,添加当前机器的公钥
# 注意,分支得正确
[root@tomcat-10 ~/springboot-bucket]#git push -u origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 328 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.3]
To git@gitee.com:yuco/linux0224.git
7d33b7e..72c4941 master -> master
Branch master set up to track remote branch master from origin.
此时可以去代码仓库中,检查该文件数据了。
4.配置本地仓库、连接远程仓库
https协议
git、ssh协议
3.5 配置ssh免密推送代码
修改远程仓库的别名,改为git协议
3.6 克隆远程仓库
克隆公开仓库
无需账号校验
git clone https://gitee.com/xiongliding/wx.git
克隆自己公司的代码,私有仓库
gitlab
或者 gitee
都需要身份验证
输入账户密码
或者 配置sshkey即可
远程仓库的分支代码合并,放到gitlab讲解即可