【Git版本控制 02】分支管理
目录
一、创建分支
二、切换分支
三、合并分支
四、删除分支
五、合并冲突
六、分支策略
七、bug分支
一、创建分支
# 当前仓库只有 master 一个主分支
# 可通过 git branch 是进行分支管理的命令,可通过不同参数对分支进行查看、创建、删除(base) [root@localhost gitcode]# cat .git/HEAD
ref: refs/heads/master
(base) [root@localhost gitcode]# cat .git/refs/heads/master
84b615bfb313b40010c263cbadc67f24ce1ed1d3
(base) [root@localhost gitcode]# git branch
* master
(base) [root@localhost gitcode]# git branch dev
(base) [root@localhost gitcode]# git branchdev
* master
(base) [root@localhost gitcode]# ls .git/refs/heads/
dev master
(base) [root@localhost gitcode]# cat .git/refs/heads/*
84b615bfb313b40010c263cbadc67f24ce1ed1d3
84b615bfb313b40010c263cbadc67f24ce1ed1d3
(base) [root@localhost gitcode]# # * 表示当前 HEAD 指向的分支是 master 分支
# git branch 只能查看本地分支,git branch -r 可查看远程分支
二、切换分支
(base) [root@localhost gitcode]# git checkout dev
切换到分支 'dev'
(base) [root@localhost gitcode]# cat .git/HEAD
ref: refs/heads/dev
(base) [root@localhost gitcode]# git branch
* devmaster
(base) [root@localhost gitcode]#
# 在新分支上修改文件内容(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: dev
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "modify file1 for dev"
[dev 088ce6d] modify file1 for dev1 file changed, 1 insertion(+)
(base) [root@localhost gitcode]# git checkout master
切换到分支 'master'
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
(base) [root@localhost gitcode]# # 为什么 dev分支 和 master分支 上同一个文件的内容不一样呢?
# 我们可以看到 dev分支和 master分支 上两者指向的提交是不一样的(base) [root@localhost gitcode]# cat .git/refs/heads/dev
088ce6d478daaadbd94870ceebd47bd05bf1b4e1
(base) [root@localhost gitcode]# cat .git/refs/heads/master
84b615bfb313b40010c263cbadc67f24ce1ed1d3
(base) [root@localhost gitcode]#
三、合并分支
# 先切回到 master分支,再通过 git merge 合并 dev分支(base) [root@localhost gitcode]# git checkout master
切换到分支 'master'
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
(base) [root@localhost gitcode]# git merge dev
更新 84b615b..088ce6d
Fast-forwardfile1 | 1 +1 file changed, 1 insertion(+)
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: dev
(base) [root@localhost gitcode]#
Fast-forward代表“快进模式”,也就是直接把master指向dev的当前提交,所以合并速度非常快。
四、删除分支
合并完成后, dev分⽀ 对于我们来说就没⽤了,那么 dev分⽀ 就可以被删除掉,注意如果当前正处于某分⽀下,就不能删除当前分⽀。
(base) [root@localhost gitcode]# git branch
* devmaster
(base) [root@localhost gitcode]# git branch -d dev
error: 无法删除您当前所在的分支 'dev'。
(base) [root@localhost gitcode]# git checkout master
切换到分支 'master'
(base) [root@localhost gitcode]# git branch -d dev
已删除分支 dev(曾为 088ce6d)。
(base) [root@localhost gitcode]# git branch
* master
(base) [root@localhost gitcode]#
因为创建、合并和删除分⽀⾮常快,所以Git⿎励你使⽤分⽀完成某个任务,合并后再删掉分⽀,这和直接在master分⽀上⼯作效果是⼀样的,但过程更安全。
五、合并冲突
在实际分⽀合并的时候,并不是想合并就能合并成功的,有时候可能会遇到代码冲突的问题。
# git checkout -b 可以创建并跳转到新分支
# 分别在 dev1分支 和 master分支上对file1文件修改并提交(base) [root@localhost gitcode]# git checkout -b dev1
切换到一个新分支 'dev1'
(base) [root@localhost gitcode]# git branch
* dev1master
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: dev1
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "modify file1 for dev1"
[dev1 77f1455] modify file1 for dev11 file changed, 1 insertion(+), 1 deletion(-)
(base) [root@localhost gitcode]# git checkout master
切换到分支 'master'
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: dev
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "modify file1 for master"
[master b7534ec] modify file1 for master1 file changed, 1 insertion(+), 1 deletion(-)
(base) [root@localhost gitcode]#
这种情况下,Git只能试图把各⾃的修改合并起来,但这种合并就可能会有冲突,如下所⽰:
(base) [root@localhost gitcode]# git branchdev1
* master
(base) [root@localhost gitcode]# git merge dev1
自动合并 file1
冲突(内容):合并冲突于 file1
自动合并失败,修正冲突然后提交修正的结果。
(base) [root@localhost gitcode]# git status
# 位于分支 master
# 您有尚未合并的路径。
# (解决冲突并运行 "git commit")
#
# 未合并的路径:
# (使用 "git add <file>..." 标记解决方案)
#
# 双方修改: file1
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
<<<<<<< HEAD
write sth. for new branch: master
=======
write sth. for new branch: dev1
>>>>>>> dev1
(base) [root@localhost gitcode]#
Git会⽤ <<<<<<<,=======,>>>>>>> 来标记出不同分⽀的冲突内容,此时我们必须要⼿动调整冲突代码,并需要再次提交修正后的结果!!
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "modify file1 for master and dev1"
[master 0dc19d0] modify file1 for master and dev1
(base) [root@localhost gitcode]# git status
# 位于分支 master
无文件要提交,干净的工作区
(base) [root@localhost gitcode]#
# 用带参数的 git log 也可以看到分支合并情况(base) [root@localhost gitcode]# git log --graph --pretty=oneline --abbrev-commit
* 0dc19d0 modify file1 for master and dev1
|\
| * 77f1455 modify file1 for dev1
* | b7534ec modify file1 for master
|/
* 088ce6d modify file1 for dev
* 84b615b delete file3
* 0f28717 delete file4
* c31b56a modigy: add vertion2
* 167def0 modify: add vertion1
* 7df1e32 modify: file1
* f2e9210 Add three files
* fc3a350 Add first file
(base) [root@localhost gitcode]#
# 分支使用完最好删除掉(base) [root@localhost gitcode]# git branch -d dev1
已删除分支 dev1(曾为 77f1455)。
(base) [root@localhost gitcode]# git branch
* master
(base) [root@localhost gitcode]#
六、分支策略
通常合并分⽀时,如果可能,Git会采⽤ Fast forward 模式。
在这种 Fast forward 模式下,删除分⽀后,查看分⽀历史时,会丢掉分⽀信息,看不出来最新提交到底是 merge 进来的还是正常提交的。
但在合并冲突部分,我们也看到通过解决冲突问题,会再进⾏⼀次新的提交。
那么这就不是 Fast forward 模式了,这样的好处是,从分⽀历史上就可以看出分⽀信息。
Git ⽀持我们强制禁⽤ Fast forward 模式,那么就会在 merge 时⽣成⼀个新的 commit ,这样,从分⽀历史上就可以看出分⽀信息。
# 新建 dev2分支 并在新分支上修改 file1(base) [root@localhost gitcode]# git checkout -b dev2
切换到一个新分支 'dev2'
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
write sth. for new branch: dev2
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "modify file1 for dev2"
[dev2 13c3c71] modify file1 for dev21 file changed, 1 insertion(+)
(base) [root@localhost gitcode]#
# 使用 git -merge --no-ff 合并分支会提交一个新的 commit(base) [root@localhost gitcode]# git checkout master
切换到分支 'master'
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
(base) [root@localhost gitcode]# git merge --no-ff -m "merge with no-ff: dev2" dev2
Merge made by the 'recursive' strategy.file1 | 1 +1 file changed, 1 insertion(+)
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
write sth. for new branch: dev2
(base) [root@localhost gitcode]# git log --graph --pretty=oneline --abbrev-commit
* cb70524 merge with no-ff: dev2
|\
| * 13c3c71 modify file1 for dev2
|/
* 0dc19d0 modify file1 for master and dev1
|\
| * 77f1455 modify file1 for dev1
* | b7534ec modify file1 for master
|/
* 088ce6d modify file1 for dev
* 84b615b delete file3
* 0f28717 delete file4
* c31b56a modigy: add vertion2
* 167def0 modify: add vertion1
* 7df1e32 modify: file1
* f2e9210 Add three files
* fc3a350 Add first file
(base) [root@localhost gitcode]#
可以看出,在 --no-ff 模式下,merge后的分支图为:
所以在合并分⽀时,加上 --no-ff 参数就可以⽤普通模式合并,合并后的历史有分⽀,能看出来曾经做过合并,⽽ fast forward 合并就看不出来曾经做过合并。
分支管理原则:
- master分⽀应该是⾮常稳定的,也就是仅⽤来发布新版本,平时不能在上⾯⼲活;
- ⼲活都在dev分⽀上,也就是说,dev分⽀是不稳定的,到某个时候,⽐如1.0版本发布时,再把dev分⽀合并到master上,在master分⽀发布1.0版本;
七、bug分支
假如我们现在正在 dev2 分⽀上进⾏开发,开发到⼀半,突然发现 master 分⽀上⾯有bug,需要解决。在Git中,每个bug都可以通过⼀个新的临时分⽀来修复,修复后,合并分⽀,然后将临时分⽀删除。
可现在 dev2 的代码在⼯作区中开发了⼀半,还⽆法提交,怎么办?
(base) [root@localhost gitcode]# git checkout dev2
切换到分支 'dev2'
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
write sth. for new branch: dev2
this is a bug ...
(base) [root@localhost gitcode]# git status
# 位于分支 dev2
# 尚未暂存以备提交的变更:
# (使用 "git add <file>..." 更新要提交的内容)
# (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
# 修改: file1
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
(base) [root@localhost gitcode]#
# Git提供了 git stash 命令可以将当前工作区信息进行储藏
# 被储藏的内容可以在将来的某个时间恢复出来(base) [root@localhost gitcode]# git stash
Saved working directory and index state WIP on dev2: 13c3c71 modify file1 for dev2
HEAD 现在位于 13c3c71 modify file1 for dev2
(base) [root@localhost gitcode]# git status
# 位于分支 dev2
无文件要提交,干净的工作区
(base) [root@localhost gitcode]#
# 储藏 dev2 ⼯作区之后,由于我们要基于master分⽀修复bug,
# 所以需要切回 master 分⽀,再新建临时分⽀来修复bug(base) [root@localhost gitcode]# git checkout master
切换到分支 'master'
(base) [root@localhost gitcode]# git checkout -b fix_bug
切换到一个新分支 'fix_bug'
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
write sth. for new branch: dev2
fix a bug here!
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "fix a bug"
[fix_bug 1ec9fbd] fix a bug1 file changed, 1 insertion(+)
(base) [root@localhost gitcode]#
# 修复完成后,切换到 master 分⽀,并完成合并,最后删除 fix_bug 分⽀(base) [root@localhost gitcode]# git checkout master
切换到分支 'master'
(base) [root@localhost gitcode]# git merge --no-ff -m "merge fix_bug branch" fix_bug
Merge made by the 'recursive' strategy.file1 | 1 +1 file changed, 1 insertion(+)
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
write sth. for new branch: dev2
fix a bug here!
(base) [root@localhost gitcode]# git branch -d fix_bug
已删除分支 fix_bug(曾为 1ec9fbd)。
(base) [root@localhost gitcode]#
# bug的修复⼯作已经做完了,我们还要继续回到 dev2 分⽀进⾏开发。
# ⼯作区是⼲净的,需要恢复现场
# git stash list 查看工作现场列表
# git stash pop 恢复工作现场(base) [root@localhost gitcode]# git checkout dev2
切换到分支 'dev2'
(base) [root@localhost gitcode]# git status
# 位于分支 dev2
无文件要提交,干净的工作区
(base) [root@localhost gitcode]# git stash list
stash@{0}: WIP on dev2: 13c3c71 modify file1 for dev2
(base) [root@localhost gitcode]# git stash pop
# 位于分支 dev2
# 尚未暂存以备提交的变更:
# (使用 "git add <file>..." 更新要提交的内容)
# (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
# 修改: file1
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
丢弃了 refs/stash@{0} (f9841933f9d2d3112f4262fc0e5c9f882fea7fd7)
(base) [root@localhost gitcode]# git stash list
(base) [root@localhost gitcode]#
# 恢复完代码之后我们便可以继续完成开发,开发完成后便可以进⾏提交
# 但是修复bug的内容并没有在dev2中显示(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
write sth. for new branch: dev2
this is a bug ...
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "modify file1 for dev2"
[dev2 030cb5d] modify file1 for dev21 file changed, 1 insertion(+), 1 deletion(-)
(base) [root@localhost gitcode]#
Master 分⽀⽬前最新的提交,是要领先于新建 dev2 时基于的 master 分⽀的提交的,所以我们
在 dev2 中当然看不⻅修复bug的相关代码。
我们的最终⽬的是要让 master 合并 dev2 分⽀的,那么正常情况下我们切回 master 分⽀直接合
并即可,但这样其实是有⼀定⻛险的。
因为在合并分⽀时可能会有冲突,⽽代码冲突需要我们⼿动解决(在 master 上解决)。我们⽆法保证对于冲突问题可以正确地⼀次性解决掉,因为在实际的项⽬中,代码冲突不只⼀两⾏那么简单,有可能⼏⼗上百⾏,甚⾄更多,解决的过程中难免⼿误出错,导致错误的代码被合并到master 上。
解决这个问题的⼀个好的建议就是:最好在⾃⼰的分⽀上合并下 master ,再让 master 去合并
dev ,这样做的⽬的是有冲突可以在本地分⽀解决并进⾏测试,⽽不影响 master 。
# dev2 合并 master(base) [root@localhost gitcode]# git branch
* dev2master
(base) [root@localhost gitcode]# git merge master
自动合并 file1
冲突(内容):合并冲突于 file1
自动合并失败,修正冲突然后提交修正的结果。
(base) [root@localhost gitcode]#
# 发生冲突,将冲突解决并重新提交(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
write sth. for new branch: dev2
<<<<<<< HEAD
this is a bug ...
=======
fix a bug here!
>>>>>>> master
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
write sth. for new branch: master
write sth. for new branch: dev1
write sth. for new branch: dev2
i am coding ... done!
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "merge master"
[dev2 9604340] merge master
(base) [root@localhost gitcode]# git status
# 位于分支 dev2
无文件要提交,干净的工作区
(base) [root@localhost gitcode]#
# 切回master,合并dev2(base) [root@localhost gitcode]# git checkout master
切换到分支 'master'
(base) [root@localhost gitcode]# git merge dev2
更新 1bcd87b..9604340
Fast-forwardfile1 | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
(base) [root@localhost gitcode]# git status
# 位于分支 master
无文件要提交,干净的工作区
(base) [root@localhost gitcode]# git branch -d dev2
已删除分支 dev2(曾为 9604340)。
(base) [root@localhost gitcode]#
相关文章:

【Git版本控制 02】分支管理
目录 一、创建分支 二、切换分支 三、合并分支 四、删除分支 五、合并冲突 六、分支策略 七、bug分支 一、创建分支 # 当前仓库只有 master 一个主分支 # 可通过 git branch 是进行分支管理的命令,可通过不同参数对分支进行查看、创建、删除(base) [rootloc…...
基金分类
一、按基金运作方式分类 (一)封闭式基金 是基金份额总额在期限内固定不变,在期限内不可申购和赎回。 (二)开放式基金 是基金份额总额不固定,在期限内可以申购和赎回。 这里的开放式基金特指传统的开放式基…...

kali系统概述、nmap扫描应用、john破解密码、抓包概述、以太网帧结构、抓包应用、wireshark应用、nginx安全加固、Linux系统加固
目录 kali nmap扫描 使用john破解密码 抓包 封装与解封装 网络层数据包结构 TCP头部结构编辑 UDP头部结构 实施抓包 安全加固 nginx安全 防止缓冲区溢出 Linux加固 kali 实际上它就是一个预安装了很多安全工具的Debian Linux [rootmyhost ~]# kali resetkali …...
Spring Cloud 路由和消息传递 (HTTP 路由)
Spring Cloud 路由 Spring Cloud 路由是指将请求路由到特定服务的机制。Spring Cloud 提供了多种路由机制,包括: Ribbon: 一个基于 HTTP 和 TCP 的客户端负载均衡工具,提供软负载均衡、故障转移等功能。Feign: 一个声明式的 HTTP 客户端&am…...

【PyQt】12-滑块、计数控件
文章目录 前言一、滑块控件 QSlider运行结果 二、计数器控件 QSpinBox运行结果 总结 前言 1、滑块控件 2、计数控件 一、滑块控件 QSlider #Author :susocool #Creattime:2024/2/15 #FileName:28-滑块控件 #Description: 通过滑块选择字体大小 import sys from PyQ…...

【牛客面试必刷TOP101】Day21.BM11 链表相加(二)和BM12 单链表的排序
作者简介:大家好,我是未央; 博客首页:未央.303 系列专栏:牛客面试必刷TOP101 每日一句:人的一生,可以有所作为的时机只有一次,那就是现在!!!&…...

疑似针对安全研究人员的窃密与勒索
前言 笔者在某国外开源样本沙箱平台闲逛的时候,发现了一个有趣的样本,该样本伪装成安全研究人员经常使用的某个渗透测试工具的破解版压缩包,对安全研究人员进行窃密与勒索双重攻击,这种双重攻击的方式也是勒索病毒黑客组织常用的…...
Mamba-UNet:用于医学图像分割的类似UNet的纯视觉Mamba网络
摘要 在医学图像分析的最新进展中,卷积神经网络(CNN)和视觉转换器(ViT)都取得了显著的基准成绩。前者通过其卷积操作在捕获局部特征方面表现出色,而后者则通过利用自注意力机制实现了出色的全局上下文理解。然而,这两种架构在有效建模医学图像中的长距离依赖关系时都存…...
2024/2/14
1.1、若有下面的变量定义,以下语句中合法的是( A )。 int i,a[10],*p; A) pa2; B) pa[5]; C) pa[2]2; D) p&(i2); 1.2、有以下程序 …...

跟廖雪峰老师学习Git(持续更新)
Git简介 创建版本库 第一步,创建一个新目录 第二步,通过git init变成Git可以管理的仓库 把文件添加到文本库,不要使用Windows自带的记事本! 我用的是VS code 创建readme.txt 放入库中 commit可以一次提交很多文件࿰…...

2024,欢迎来到性价比时代
「不是XX买不起,而是YY更有性价比。」——翻开过去一年的商业消费史,这句话几乎可以贯穿始终。年轻消费者们追求性价比的眼光一旦定型,一些品牌过去被品质生活、消费升级包装出来的华丽外壳,很容易一击就碎。 胜出的「性价比之王…...
【国产MCU】-CH32V307-通用定时器(GPTM)-输入捕获模式测量脉冲
通用定时器(GPTM)-输入捕获模式测量脉冲 文章目录 通用定时器(GPTM)-输入捕获模式测量脉冲1、通用定时器(GPTM)介绍2、输入捕获模式3、驱动API介绍4、定时器输入捕获示例CH32V307的通用定时器模块包含一个16 位可自动重装的定时器(TIM2、TIM3、TIM4和TIM5),用于测量脉…...
sqlserver char,nchar varchar nvarchar的区别
在 SQL Server 中,char、nchar、varchar 和 nvarchar 是用于存储文本数据的数据类型。它们之间的区别主要在于它们所使用的字符集和存储空间方面。 char:(中文占2个字节,英文1个) char 是一种固定长度的字符数据类型&a…...

FT2232调试记录(2)
FT2232调试记录 (1)获取当前连接的FTDI设备通道个数:(2)获取当前连接的设备通道的信息:(3)配置SPI的通道:(4)如何设置GPIO:(5)DEMO测试: FT2232调…...

网络学习:数据链路层VLAN原理和配置
一、简介: VLAN又称为虚拟局域网,它是用来将使用路由器的网络分割成多个虚拟局域网,起到隔离广播域的作用,一个VLAN通常对应一个IP网段,不同VLAN通常规划到不同IP网段。划分VLAN可以提高网络的通讯质量和安全性。 二、…...

Docker的常见命令以及命令别名
常见命令 命令说明docker pull拉取镜像docker push推送镜像到DockerRegistrydocker images查看本地镜像docker rmi删除本地镜像docker run创建并允许容器docker stop停止指定容器docker start启动指定容器docker restart重新启动容器docker rm删除指定容器docker ps查看容器do…...

2024.02.14作业
1. 请编程实现二维数组的杨辉三角 #include <stdio.h> #include <stdlib.h> #include <string.h>int main() {int n;scanf("%d", &n);int a[n][n];memset(a, 0, sizeof(a));a[0][0] 1;for (int i 1; i < n; i){for (int j 0; j < i …...

SpringMVC原理(设计原理+启动原理+工作原理)
文章目录 前言正文一、设计原理1.1 servlet生命周期简述1.2 设计原理小结 二、启动原理2.1 AbstractHandlerMethodMapping 初始化 --RequestMapping注解解析2.2 DispatcherServlet 的初始化2.3 DispatcherServlet#initHandlerMappings(...) 初始化示例说明 三、工作原理 前言 …...

Java+SpringBoot构建智能捐赠管理平台
✍✍计算机编程指导师 ⭐⭐个人介绍:自己非常喜欢研究技术问题!专业做Java、Python、微信小程序、安卓、大数据、爬虫、Golang、大屏等实战项目。 ⛽⛽实战项目:有源码或者技术上的问题欢迎在评论区一起讨论交流! ⚡⚡ Java实战 |…...

ubuntu远程桌面配置以及常见问题
ubuntu桌面系统配置 ubuntu远程桌面配置如下 第一步,安装xrdp sudo apt-get isntall xrdp安装完检查一下服务是否可以正常启动, sudo systemctl status xrdp如果看到active应该就正常启动了 第二步,开启Ubuntu桌面共享 好接下来我们测试一…...

装饰模式(Decorator Pattern)重构java邮件发奖系统实战
前言 现在我们有个如下的需求,设计一个邮件发奖的小系统, 需求 1.数据验证 → 2. 敏感信息加密 → 3. 日志记录 → 4. 实际发送邮件 装饰器模式(Decorator Pattern)允许向一个现有的对象添加新的功能,同时又不改变其…...

智慧工地云平台源码,基于微服务架构+Java+Spring Cloud +UniApp +MySql
智慧工地管理云平台系统,智慧工地全套源码,java版智慧工地源码,支持PC端、大屏端、移动端。 智慧工地聚焦建筑行业的市场需求,提供“平台网络终端”的整体解决方案,提供劳务管理、视频管理、智能监测、绿色施工、安全管…...

MFC内存泄露
1、泄露代码示例 void X::SetApplicationBtn() {CMFCRibbonApplicationButton* pBtn GetApplicationButton();// 获取 Ribbon Bar 指针// 创建自定义按钮CCustomRibbonAppButton* pCustomButton new CCustomRibbonAppButton();pCustomButton->SetImage(IDB_BITMAP_Jdp26)…...

STM32标准库-DMA直接存储器存取
文章目录 一、DMA1.1简介1.2存储器映像1.3DMA框图1.4DMA基本结构1.5DMA请求1.6数据宽度与对齐1.7数据转运DMA1.8ADC扫描模式DMA 二、数据转运DMA2.1接线图2.2代码2.3相关API 一、DMA 1.1简介 DMA(Direct Memory Access)直接存储器存取 DMA可以提供外设…...

MODBUS TCP转CANopen 技术赋能高效协同作业
在现代工业自动化领域,MODBUS TCP和CANopen两种通讯协议因其稳定性和高效性被广泛应用于各种设备和系统中。而随着科技的不断进步,这两种通讯协议也正在被逐步融合,形成了一种新型的通讯方式——开疆智能MODBUS TCP转CANopen网关KJ-TCPC-CANP…...
DeepSeek 技术赋能无人农场协同作业:用 AI 重构农田管理 “神经网”
目录 一、引言二、DeepSeek 技术大揭秘2.1 核心架构解析2.2 关键技术剖析 三、智能农业无人农场协同作业现状3.1 发展现状概述3.2 协同作业模式介绍 四、DeepSeek 的 “农场奇妙游”4.1 数据处理与分析4.2 作物生长监测与预测4.3 病虫害防治4.4 农机协同作业调度 五、实际案例大…...

以光量子为例,详解量子获取方式
光量子技术获取量子比特可在室温下进行。该方式有望通过与名为硅光子学(silicon photonics)的光波导(optical waveguide)芯片制造技术和光纤等光通信技术相结合来实现量子计算机。量子力学中,光既是波又是粒子。光子本…...
PAN/FPN
import torch import torch.nn as nn import torch.nn.functional as F import mathclass LowResQueryHighResKVAttention(nn.Module):"""方案 1: 低分辨率特征 (Query) 查询高分辨率特征 (Key, Value).输出分辨率与低分辨率输入相同。"""def __…...
Go 并发编程基础:通道(Channel)的使用
在 Go 中,Channel 是 Goroutine 之间通信的核心机制。它提供了一个线程安全的通信方式,用于在多个 Goroutine 之间传递数据,从而实现高效的并发编程。 本章将介绍 Channel 的基本概念、用法、缓冲、关闭机制以及 select 的使用。 一、Channel…...

代码规范和架构【立芯理论一】(2025.06.08)
1、代码规范的目标 代码简洁精炼、美观,可持续性好高效率高复用,可移植性好高内聚,低耦合没有冗余规范性,代码有规可循,可以看出自己当时的思考过程特殊排版,特殊语法,特殊指令,必须…...