【Git学习笔记】Git分支管理策略及其结构原理分析

news2025/3/19 14:37:02

【Git学习笔记】Git分支管理策略及其结构原理分析

🔥个人主页大白的编程日记

🔥专栏Git学习笔记


文章目录

  • 【Git学习笔记】Git分支管理策略及其结构原理分析
    • 前言
    • 一.合并冲突
    • 二. 分支管理策略
      • 2.1 分支策略
      • 2.2 bug分支
      • 2.3 删除临时分支
      • 2.4 小结
    • 后言

前言

哈喽,各位小伙伴大家好!今天开始我们就进入新的篇章——Git学习!。今天我们来讲一下Git初始及其结构原理分析。话不多说,我们进入正题!向大厂冲锋
在这里插入图片描述

一.合并冲突

可是,在实际分支合并的时候,并不是想合并就能合并成功的,有时候可能会遇到代码冲突的问题。

b dev1 -步完成创建并切换的动作,示例如下:
为了演示这问题,创建一个新的分支 dev1,并切换至目标分支,我们可以使用 git checkout

qcj@139 - 159 - 150 - 152:~/ gitcodes git checkout
- b dev1
Switched to a new branch 'dev1'
qcje139 - 159 - 150 - 152 : ~/ gitcodes git branch
* dev1
master

在 dev1分支下修改 ReadMe文件,更改文件内容如下,并进行一次提交,如

qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello versionl
hello version2
hello version3
write bbb for new branch
# 将 aaa 该为 bbb
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add .
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"modify ReadMe"
Idev1 0854245]modify ReadMe
1 file changed, l insertion(+), l deletion(-)

切换至 master分支,观察 ReadMe 文件内容:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout master
Switched to branch 'master
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello versionl
hello version2
hello version3
write aaa for new branch

我们发现,切回来之后,文件内容由变成了老的版本,这种现象很正常,我们现在也完全能理解。

此时在 master 分支上,我们对 ReadMe 文件再进行一次修改,并进行提交,如下

qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch
dev1
* master
qcj@139 - 159 - 150 - 152:~/ gitcode$ vim ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$
cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
write ccc for new branch
qcje139 - 159 - 150 - 152:~/ gitcode$ git add
qcje139 - 159 - 150 - 152 : ~/ gitcode$ git commit - m"modify ReadMe"
c10f6d0] modify ReadMe
[master
1 file changed,
l insertion(+), 1 deletion(-)

现在, master 分支和 dev1分支各自都分别有新的提交,变成了这样

这种情况下,Git 只能试图把各自的修改合并起来,但这种合并就可能会有冲突,如下所示:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git merge devl
Auto - merging ReadMe
CONFLICT(content) : Merge conflict in ReadMe
Automatic merge failed; fix conflicts and then commit the result
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths :
(use "git add <file>.
    to mark resolution)
    both modified :
ReadMe
no changes added to commit(use "git add" and /or "git commit -a")

发现 ReadMe 文件有冲突后,可以直接查看文件内容,要说的是 Git 会用 <<<<<<<,二二二二二二,>>>>>>>来标记出不同分支的冲突内容,如下所示:

qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
<<<<<< < HEAD
write ccc for new branch
write bbb for new branch
dev1

此时我们必须要手动调整冲突代码,并需要再次提交修正后的结果!!(再次提交很重要,切勿忘记)

hyb@139-159-150-152:~/gitcode$ cat ReadMe
hello bit
hello git
hello world
hello versionl
hello version2
hello version3
write bbb for new branch
hybe139-159-150-152:~/gitcode$ git add
hyb@139-159-150-152:~/gitcode$ git commit -m"merge ReadMe"
master 2976afc]merge ReadMe

到这里冲突就解决完成,此时的状态变成了

用带参数的 gitlog也可以看到分支的合并情况,具体大家可以自行搜索 git log 的用法:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git log --graph --pretty = oneline --abbrev - commit
* 2976afc(HEAD->master) merge ReadMe
| \
| *c594fd1(dev1) modify ReadMe
* | c10f6d0 modify ReadMe
|/

最后,不要忘记 dev1 分支使用完毕后就可以删除了:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch
* master
qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch - d dev1
Deleted branch devl(was c594fd1).

在这里插入图片描述

二. 分支管理策略

通常合并分支时,如果可能,Git 会采用 Fast forward 模式。还记得如果我们采用 Fast forward 模式之后,形成的合并结果是什么呢?回顾一下

在这种 Fast forward 模式下,删除分支后,查看分支历史时,会丢掉分支信息,看不出来最新提交到底是 merge 进来的还是正常提交的。

但在合并冲突部分,我们也看到通过解决冲突问题,会再进行一次新的提交,得到的最终状态为:

那么这就不是 Fast forward 模式了,这样的好处是,从分支历史上就可以看出分支信息。例如我们现在已经删除了在合并冲突部分创建的 dev1 分支,但依旧能看到 master 其实是由其他分支合并得到:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git log --graph --pretty = oneline --abbrev - commit
* 2976afc(HEAD->master) merge ReadMe
| \
| *c594fd1 modify ReadMe
* | c10f6d0 modify ReadMe
|/

Git支持我们强制禁用 Fast forward 模式,那么就会在 merge 时生成一个新的 commit ,这样从分支历史上就可以看出分支信息。

下面我们实战-下 --no-ff方式的 git merge 。首先,创建新的分支 dev2,并切换至新的分支;

qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout - b dev2
Switched to a new branch 'dev2'

修改 ReadMe 文件,并提交一个新的commit:

qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
write bbb for new branch
a, b, c, d
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add .
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"modify ReadMe"
[dev2 41b082f] modify ReadMe
1 file changed, 1 insertion(+)

切回master分支,开始合并:

hyb@139 - 159 - 150 - 152:~/ gitcode$ git checkout master
Switched to branch'master'
hybe139 - 159 - 150 - 152 : ~/ gitcode$ git merge --no - ff - m "merge with no-ff" dev2
Merge made by the recursive'strategy.
ReadMe1 +
1 file changed, l insertion(+)
hyba139 - 159 - 150 - 152 : ~/ gitcodes cat ReadMe
hello bit
hello git
hello world
hello versionl
hello version2
hello version3
write bbb for new branch
a, b, c, d

请注意 --no-ff 参数,表示禁用 Fast forward 模式。
禁用 Fast forward 模式后合并会创建-个新的 commit,所以加上-m 参数,把描述写进去。

qcj@139 - 159 - 150 - 152:~/ gitcode$ git log --graph --pretty = oneline --abbrev - commit
* 5bd16b4(HEAD->master) merge with no - ff
| \
| *41b082f(dev2) modify ReadMe
|/

可以看到,不使用 Fast forward 模式,merge后就像这样,

所以在合并分支时,加上–no-ff 参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而 fast forward 合并就看不出来曾经做过合并。

2.1 分支策略

在实际开发中,我们应该按照几个基本原则进行分支管理:

首先,master分支应该是非常稳定的,也就是仅用来发布新版本,平时不能在上面干活;

那在哪干活呢?干活都在dev分支上,也就是说,dev分支是不稳定的,到某个时候,比如1.0版本发布时,再把dev分支合并到master上,在master分支发布1.0版本;

你和你的小伙伴们每个人都在dev分支上干活,每个人都有自己的分支,时不时地往dev分支上合并就可以了。

所以,团队合作的分支看起来就像这样!

2.2 bug分支

假如我们现在正在 dev2 分支上进行开发,开发到一半,突然发现 master分支上面有bug,需要解决。在Git中,每个bug都可以通过一个新的临时分支来修复,修复后,合并分支,然后将临时分支删除。

可现在 dev2 的代码在工作区中开发了一半,还无法提交,怎么办?例如:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch
* dev2
master
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
write bbb for new branch
a, b, c, d
i am coding ...
qcja139 - 159 - 150 - 152:~/ gitcode$ git status
On branch dev2
Changes not staged for commit :
    (use "git add <file>..." to update what will be committed)
    (use "git restore <file>..." to discard changes in working directory)
    modified:
ReadMe
no changes added to commit(use "git add" and /or "git commit -a")

Git提供了 git stash 命令,可以将当前的工作区信息进行储藏,被储藏的内容可以在将来某个时间恢复出来。

qcj@139 - 159 - 150 - 152:~/ gitcodes git stash
Saved working directory and index state WIP on dev2 : 41b082f modify ReadMe
qcja139 - 159 - 150 - 152 : ~/ gitcodeS git status
On branch dev2
nothing to commit, working tree clean

因此可以放心地创建分用 git status 查看工作区,就是干净的(除非有没有被 Git 管理的文件)支来修复bug。

储藏 dev2 工作区之后,由于我们要基于master分支修复 bug,所以需要切回 master 分支,再新建临时分支来修复 bug,示例如下

qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout master
Switched to branch 'master'
qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout - b fix bug
Switched to a new branch 'fix_bug'
qcj@139 - 159 - 150 - 152:~/ gitcode$ vim ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcodes cat ReadMe
hello bit
hello git
hello world
hello versionl
hello version2
hello version3
write bbb for new branch
a, b, c, d, e
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"fix bug'
[fix bug 4bbcoc4] fix bug
1 file changed, 1 insertion(+), 1 deletion(-)

修复完成后,切换到 master分支,并完成合并,最后删除fix_bug 分支

qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout master
Switched to branch 'master'
qcje139 - 159 - 150 - 152 : ~/ gitcode$ git merge
: --no - ff - m"merge fix_bug branch
fix_bug
Merge made by the 'recursive'strategy.
ReadMe2 + -
1 file changed, l insertion(+), 1 deletion(-)
qcja139 - 159 - 150 - 152 : ~/ gitcodes cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
write bbb for new branch
a, b, c, d, e
qcje139 - 159 - 150 - 152:~/ gitcode$ git branch - d fix_bug
Deleted branch fix bug(was 4bbc0c4).

至此,bug的修复工作已经做完了,我们还要继续回到 dev2 分支进行开发。切换回 dev2 分支:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout dev2
Switched to branch 'dev2
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch dev2
nothing to commit, working tree clean

工作区是干净的,刚才的工作现场存到哪去了?用 git stash list 命令看看:

qcj@139 - 159 - 150 - 152:~/ gitcodes git stash list
stash@{o}: WIP on dev2 : 41b082f modify ReadM

工作现场还在,Git 把stash 内容存在某个地方了,但是需要恢复一下,如何恢复现场呢?我们可以使用 git stash pop 命令,恢复的同时会把 stash 也删了,示例如下:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git stash pop
On branch dev2
Changes not staged for commit :
    (use "git add <file>..." to update what will be committed)
    ." to discard changes in working directory)
    (use "git restore <file>...
        modified:
ReadMe
no changes added to commit(use "git add" and /or "git commit -a")
Dropped refs / stashe{ 0 }(4f873250b3503687b5efd26196776aee7e3724c2)

再次查看的时候,我们已经发现已经没有现场可以恢复了

hyb@139-159-150-152:~/gitcode$ git stash list
hyb@139-159-150-152:~/gitcode$

另外,恢复现场也可以采用 git stash apply 恢复,但是恢复后,stash内容并不删除,你需要用git stash drop 来删除;

你可以多次stash,恢复的时候,先用git stash list 查看,
然后恢复指定的stash,用命令git stash apply stash@{o},这部分请同学们自行使用。

恢复完代码之后我们便可以继续完成开发,开发完成后便可以进行提交,例如:

qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
write bbb for new branch
a, b, c, d
i am coding ...
Done!
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add .
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"modify ReadMe"
[dev2 ed0916d] modify ReadMe
1 file changed, 1 insertion(+)

但我们注意到了,修复 bug的内容,并没有在 dev2上显示。此时的状态图为:

Master 分支目前最新的提交,是要领先于新建 dev2 时基于的 master 分支的提交的,所以我们在 dev2 中当然看不见修复 bug 的相关代码。

我们的最终目的是要让 master 合并 dev2 分支的,那么正常情况下我们切回 master 分支直接合并即可,但这样其实是有一定风险的。

是因为在合并分支时可能会有冲突,而代码冲突需要我们手动解决(在 master 上解决)。我们无法保证对于冲突问题可以正确地一次性解决掉,因为在实际的项目中,代码冲突不只一两行那么简单,有可能几十上百行,甚至更多,解决的过程中难免手误出错,导致错误的代码被合并到 master 上。此时的状态为:

解决这个问题的·个好的建议就是:最好在自己的分支上合并下master,再让master去合并dev ,这样做的目的是有冲突可以在本地分支解决并进行测试,而不影响 master 。此时的状态为:

对应的实操演示如下,要说明的是,以下演示的merge操作,没有使用–no-ff,但上述的图示是禁用 Fast forward 了模式后得出的,主要是为了方便解释问题。

# dev合并master--no - ff,但上述的图⽰是
qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch
* dev2
master
qcj@139 - 159 - 150 - 152:~/ gitcode$ git merge master
Auto - merging ReadMe
CONFLICT(content) : Merge conflict in ReadMe
Automatic merge failed; fix conflicts and then commit the result.
#发⽣冲突
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
write bbb for new branch
<<<<<<< HEAD
a, b, c, d
i am coding ... Done!
====== =
a, b, c, d, e
>>>>>> > master
qcj@139 - 159 - 150 - 152:~/ gitcode$ vim ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
write bbb for new branch
a, b, c, d, e
i am coding ... Done!
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add .
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"merge master"
[dev2 447d29f] merge master
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch dev2
nothing to commit, working tree clean
qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout master
Switched to branch 'master'
qcj@139 - 159 - 150 - 152:~/ gitcode$ git merge dev2
Updating 193421f..447d29f
Fast - forward
ReadMe | 1 +
1 file changed, 1 insertion(+)
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
nothing to commit, working tree clean
qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch - d dev2
Deleted branch dev2(was 447d29f).


2.3 删除临时分支

软件开发中,总有无穷无尽的新的功能要不断添加进来。

添加一个新功能时,你肯定不希望因为一些实验性质的代码,把主分支搞乱了,所以,每添加一个新功能,最好新建一个分支,我们可以将其称之为 feature 分支,在上面开发,完成后,合并,最后,删除该 feature 分支。

可是,如果我们今天正在某个 feature 分支上开发了一半,被产品经理突然叫停,说是要停止新功能的开发。虽然白干了,但是这个 feature 分支还是必须就地销毁,留着无用了。这时使用传统的 git branch -d 命令删除分支的方法是不行的。演示如下:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout - b dev3
Switched to a new branch 'dev3'
qcj@139 - 159 - 150 - 152:~/ gitcode$ vim ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
write bbb for new branch
a, b, c, d, e
i am coding ... Done!
i am writing new features ...
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add .
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"modify ReadMe for new features"
[dev3 cd2f149] modify ReadMe for new features
1 file changed, 1 insertion(+)
qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout master
Switched to branch 'master'
qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch - d dev3
error : The branch 'dev3' is not fully merged.
If you are sure you want to delete it, run 'git branch -D dev3'.

直接使用传统的删除分支的方法不行,按照提示,有了如下方式:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch - D dev3
Deleted branch dev3(was cd2f149).
qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch
* master

2.4 小结

  • 分支在实际中有什么用呢?假设你准备开发一个新功能,但是需要两周才能完成,第一周你写了50%的代码,如果立刻提交,由于代码还没写完,不完整的代码库会导致别人不能干活了。如果等代码全部写完再一次提交,又存在丢失每天进度的巨大风险。
  • 现在有了分支,就不用怕了。你创建了一个属于你自己的分支,别人看不到,还继续在原来的分支上正常工作,而你在自己的分支上干活,想提交就提交,直到开发完毕后,再一次性合并到原来的分支上,这样,既安全,又不影响别人工作。
  • 并且 Git 无论创建、切换和删除分支,Git在1秒钟之内就能完成!无论你的版本库是1个文件还是1万个文件。

后言

这就是Git初始及其结构原理分析。大家自己好好消化!今天就分享到这!感谢各位的耐心垂阅!咱们下期见!拜拜~

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2317849.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Spring Cloud Alibaba Nacos 2023.X 配置问题

文章目录 问题现象&#xff08;一&#xff09;解决方法&#xff08;一&#xff09;问题现象&#xff08;二&#xff09;解决方法&#xff08;二&#xff09;问题现象&#xff08;三&#xff09;解决方法&#xff08;三&#xff09; 问题现象&#xff08;一&#xff09; Spring…

厨卫行业供应链产销协同前中后大平台现状需求分析报告+P120(120页PPT)(文末有下载方式)

资料解读&#xff1a;厨卫行业供应链产销协同前中后大平台现状需求分析报告 详细资料请看本解读文章的最后内容。在当前厨卫行业竞争激烈的市场环境下&#xff0c;企业的发展战略和业务模式创新至关重要。本次解读的报告围绕某厨卫企业展开&#xff0c;深入探讨其供应链产销协同…

我在哪,要去哪

在直播间听到一首好听的歌《我在哪&#xff0c;要去哪》-汤倩。 遇见的事&#xff1a;21~24号抽调去招生。 感受到的情绪&#xff1a;公假吗&#xff1f;给工作量吗&#xff1f;月工作量不够扣钱吗&#xff1f;报销方便吗&#xff1f;有事情&#xff0c;从来不解决后顾&#x…

SpringBoot-2整合MyBatis以及基本的使用方法

目录 1.引入依赖 2.数据库表的创建 3.数据源的配置 4.编写pojo类 5.编写controller类 6.编写接口 7.编写接口的实现类 8.编写mapper 1.引入依赖 在pom.xml引入依赖 <!-- mysql--><dependency><groupId>com.mysql</groupId><artifac…

本周安全速报(2025.3.11~3.17)

合规速递 01 瑞士出台新规&#xff1a;关基设施遭遇网络攻击需在24小时内上报 原文: https://www.bleepingcomputer.com/news/security/swiss-critical-sector-faces-new-24-hour-cyberattack-reporting-rule/ 新规要求&#xff0c;关键基础设施组织发现网络攻击后&…

【css酷炫效果】纯CSS实现瀑布流加载动画

【css酷炫效果】纯CSS实现瀑布流加载动画 缘创作背景html结构css样式完整代码基础版进阶版(无限往复加载) 效果图 想直接拿走的老板&#xff0c;链接放在这里&#xff1a;https://download.csdn.net/download/u011561335/90492012 缘 创作随缘&#xff0c;不定时更新。 创作…

咖啡点单小程序毕业设计(JAVA+SpringBoot+微信小程序+完整源码+论文)

✌全网粉丝20W,csdn特邀作者、博客专家、CSDN新星计划导师、java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取项目下载方式&#x1f345; 一、项目背景介绍&#xff1a; 随着社会的快速发展和…

网络编程套接字【端口号/TCPUDP/网络字节序/socket编程接口/UDPTCP网络实验】

网络编程套接字 0. 前言1. 认识端口号2. 认识TCP和UDP协议3. 网络字节序4. socket编程接口5. 实现一个简单的UDP网络程序5.1 需求分析5.2 头文件准备5.3 服务器端设计5.4 客户端设计5.5 本地测试5.6 跨网络测试5.7 UDP小应用——客户端输入命令&#xff0c;服务器端执行 6. 地址…

DeepSeek 3FS 与 JuiceFS:架构与特性比较

近期&#xff0c;DeepSeek 开源了其文件系统 Fire-Flyer File System (3FS)&#xff0c;使得文件系统这一有着 70 多年历时的“古老”的技术&#xff0c;又获得了各方的关注。在 AI 业务中&#xff0c;企业需要处理大量的文本、图像、视频等非结构化数据&#xff0c;还需要应对…

Unity WebGL项目访问时自动全屏

Unity WebGL项目访问时自动全屏 打开TemplateData/style.css文件 在文件最下方添加红色框内的两行代码 使用vscode或者其他编辑器打开index.html 将按钮注释掉&#xff0c;并且更改为默认全屏

C# WPF编程-Menu

C# WPF编程-Menu 布局&#xff1a;代码&#xff1a;效果 在WPF&#xff08;Windows Presentation Foundation&#xff09;中&#xff0c;Menu控件用于创建下拉菜单或上下文菜单&#xff0c;它提供了丰富的定制选项来满足不同的应用需求。下面将介绍如何在WPF应用程序中使用Menu…

Docker和containerd之概览(Overview of Docker and Containerd)

Docker和containerd之概览 容器本质上就是一个进程。 Namespace是一种逻辑分组机制&#xff0c;允许您将集群资源划分为独立的虚拟环境。每个 Namespace 为资源提供了一个范围&#xff0c;使得不同的团队、应用程序或环境可以在同一集群中共存&#xff0c;而不会相互干扰。 C…

【多线程】线程不安全问题

文章目录 多线程不安全的原因大的层面->多线程是随机调度的容易产生死锁 小的层面->内存不可见性引入volatile关键字 指令重排序不是原子性带来的隐患 synchronized锁的互斥性及作用可重入性——解决死锁 wait()和notify()两个突然迸发出的疑问 多线程不安全的原因 大的…

【C++】树和二叉树的实现(下)

本篇博客给大家带来的是用C语言来实现数据结构树和二叉树的实现&#xff01; &#x1f41f;&#x1f41f;文章专栏&#xff1a;数据结构 &#x1f680;&#x1f680;若有问题评论区下讨论&#xff0c;我会及时回答 ❤❤欢迎大家点赞、收藏、分享&#xff01; 今日思想&#xff…

kafka指北

为自己总结一下kafka指北&#xff0c;会持续更新。创作不易&#xff0c;转载请注明出处。 目录 集群controller选举过程broker启动流程 主题创建副本分布ISRleader副本选举机制LEO 生产数据流程同步发送和异步发送 分区策略ack应答生产者发送消息的幂等性跨分区幂等性问题&…

7、vue3做了什么

大佬认为有何优点&#xff1a; 组合式api----逻辑集中、对ts有更好的支持RFC–开放了一个讨论机制&#xff0c;可以看到每一个api的提案&#xff0c;方便源码维护&#xff0c;功能扩展&#xff0c;大家一起讨论 官方rfc响应式独立&#xff0c;new Proxy&#xff0c;天生自带来…

基于大语言模型与知识图谱的智能论文生成工具开发构想

基于大语言模型与知识图谱的智能论文生成工具开发构想 一、研究背景与意义 1.1 学术写作现状分析 #mermaid-svg-FNVHG5EiEgVSCpHK {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-FNVHG5EiEgVSCpHK .error-icon{fil…

JUC大揭秘:从ConcurrentHashMap到线程池,玩转Java并发编程!

目录 JUC实现类 ConcurrentHashMap 回顾HashMap ConcurrentHashMap CopyOnWriteArrayList 回顾ArrayList CopyOnWriteArrayList: CopyOnWriteArraySet 辅助类 CountDownLatch 线程池 线程池 线程池优点 ThreadPoolExecutor 构造器各个参数含义&#xff1a; 线程…

4.3--入门知识扫盲,IPv4的头部报文解析,数据报分片,地址分类(包你看一遍全部记住)

IPv4协议&#xff1a;网络世界的快递包裹指南&#xff08;附拆箱说明书&#xff09; “IPv4就像一张明信片&#xff0c;既要写清楚地址&#xff0c;又要控制大小别超重” —— 某网络工程师的桌面铭牌 一、IPv4报头&#xff1a;快递面单的终极艺术 1.1 报头结构图&#xff08;…

苍穹外卖-阿里云OSS使用

第一步&#xff1a; package com.sky.properties;import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component;Component ConfigurationProperties(prefix "sky.alioss") …