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

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

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

🔥专栏Git学习笔记


文章目录

  • 【Git学习笔记】Git结构原理及其分支管理模型分析
    • 前言
    • 一.认识工作区、暂存区、版本库
      • 1.1 版本回退
      • 1.2 撤销修改
      • 1.3 删除文件
    • 二. 分支管理
      • 2.1 理解分支
      • 2.2 创建分支
      • 2.3 切换分支
      • 2.4 合并分支
      • 2.5 删除分支
      • 2.6 图文分析
    • 后言

前言

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

一.认识工作区、暂存区、版本库

1.1 版本回退

之前我们也提到过,Git 能够管理文件的历史版本,这也是版本控制器重要的能力。如果有一天你发现之前的工作做的出现了很大的问题,需要在某个特定的历史版本重新开始,这个时候,就需要版本回退的功能了。

执行 git reset 命令用于回退版本,可以指定退回某一次提交的版本。要解释一下“回退”本质是要将版本库中的内容进行回退,工作区或暂存区是否回退由命令参数决定:
git reset 命令语法格式为:git reset [–soft | --mixed |- -hard] [HEAD]

  • –mixed 为默认选项,使用时可以不用带该参数。该参数将暂存区的内容退回为指定提交版本内容,工作区文件保持不变。
  • –soft 参数对于工作区和暂存区的内容都不变,只是将版本库回退到某个指定版本。
  • –hard 参数将暂存区与工作区都退回到指定版本。切记工作区有未提交的代码时不要用这个命令,因为工作区会回滚,你没有提交的代码就再也找不回了,所以使用该参数前一定要慎重。
  • HEAD 说明:
    可直接写成commitid,表示指定退回的版本
  1. HEAD 表示当前版本
  2. HEAD^ 上一个版本
  3. HEAD^^ 上上一个版本
    以此类推…
  • 可以使用 ~数字表示:
  1. HEAD~0 表示当前版本
  2. HEAD~1 上一个版本
  3. HEAD^2 上上一个版本
    以此类推…

为了便于表述,方便测试回退功能,我们先做一些准备工作:更新3个版本的ReadMe,并分别进行3次提交,如下所示:

# 第⼀次修改提交
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"add version1"
[master cff9d1e] add version1
1 file changed, 1 insertion(+)
# 
第⼆次修改提交
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"add version2"
1 file changed, 1 insertion(+)
# 第三次修改提交
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"add version3"
[master d95c13f] add version3
1 file changed, 1 insertion(+)
# 查看历史提交记录
qcj@139 - 159 - 150 - 152:~/ gitcode$ git log --pretty = oneline
d95c13ffc878a55a25a3d04e22abfc7d2e3e1383(HEAD->master) add version3
14c12c32464d6ead7159f5c24e786ce450c899dd add version2
cff9d1e019333318156f8c7d356a78c9e49a6e7b add version1
...

现在,如果我们在提交完version3后,发现 version3编写错误,想回退到 version2,重新基于version2开始编写。由于我们在这里希望的是将工作区的内容也回退到 version 2 版本,所以需要用到–hard 参数,示例如下:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git log --pretty = oneline
d95c13ffc878a55a25a3d04e22abfc7d2e3e1383(HEAD->master) add version3
14c12c32464d6ead7159f5c24e786ce450c899dd add version2
cff9d1e019333318156f8c7d356a78c9e49a6e7b add version1
...
qcj@139 - 159 - 150 - 152:~/ gitcode$
git reset --hard
14c12c32464d6ead7159f5c24e786ce450c899dd
HEAD is now at 14c12c3 add version2
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2

我们惊奇的发现,此时 ReadMe 文件的内容,已经回退到 version2了!,当前,我们再次用 git log 查看一下提交日志,发现 HEAD 指向了version2,如下所示:

hyb@139-159-150-152:~/gitcode$ git log --pretty=oneline14c12c32464d6ead7159f5c24e786ce450c899dd (HEAD -> master) add version2cff9d1e019333318156f8c7d356a78c9e49a6e7b add version1...

到这里一般回退功能就演示完了,但现在如果我后悔了,想再回到 version3怎么办?我们可以继续使用 git reset 命令,回退到 version 3 版本,但我们必须要拿到 version 3的 commit id 去指定回退的版本。

但我们看到了 git log并不能打印出 version 3的 commit id,运气好的话我们可以从终端上去找找之前的记录,运气不好的话commitid 已经被我们搞丢了=。=

Git 还提供了⼀个git reflog 命令能补救⼀下,该命令用来记录本地的每⼀次命令。

qcj@139 - 159 - 150 - 152:~/ gitcode$
git reflog
14c12c3(HEAD->master) HEAD@{0}: reset: moving to
14c12c32464d6ead7159f5c24e786ce450c899dd
d95c13f HEAD@{1}: commit: add version3
14c12c3(HEAD->master) HEAD@{2}: commit: add version2
cff9d1e HEAD@{3}: commit: add version1
94da695 HEAD@{4}: commit: add modify ReadMe file
23807c5 HEAD@{5}: commit: add 3 files
c614289 HEAD@{6}: commit(initial) : commit my first file

这样,你就可以很方便的找到你的所有操作记录了,但 d95c13f这个是啥东西?这个是 version3 的 commit id 的部分。没错,Git 版本回退的时候,也可以使用部分 commit id 来代表目标版本。示例如下:

# 回退到v3
qcj@139 - 159 - 150 - 152:~/ gitcode$
git reset --hard d95c13f
HEAD is now at d95c13f add version3
# 查看⼯作区
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3
# 查看log
qcj@139 - 159 - 150 - 152:~/ gitcode$ git log --pretty = oneline
d95c13ffc878a55a25a3d04e22abfc7d2e3e1383(HEAD->master) add version3
14c12c32464d6ead7159f5c24e786ce450c899dd add version2
cff9d1e019333318156f8c7d356a78c9e49a6e7b add version1
94da6950d27e623c0368b22f1ffc4bff761b5b00 add modify ReadMe file
23807c536969cd886c4fb624b997ca575756eed6 add 3 files
c61428926f3853d4ec6dde904415b0e6c1dabcc6 commit my first file

往往是理想很丰满,现实很骨感。在实际开发中,由于长时间的开发了,导致 commit id 早就找不到了,可突然某一天,我又想回退到version3,那该如何操作呢?貌似现在不可能了。。

值得说的是,Git的版本回退速度非常快,因为 Git 在内部有个指向当前分支(此处是master)的HEAD指针,refs/heads/master 文件里保存当前 master 分支的最新 commit id。当我们在回退版本的时候,Git仅仅是给 refs/heads/master 中存储一个特定的version,可以简单理解成如下示意图:

1.2 撤销修改

如果我们在我们的工作区写了很长时间代码,越写越写不下去,觉得自己写的实在是垃圾,想恢复到上一个版本。

  • 情况一:对于工作区的代码,还没有 add
    你当然可以直接删掉你目前在工作区新增的代码,像这样
# 向ReadMe中新增⼀⾏代码
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
nothing to commit, working tree clean
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
This piece of code is like shit  #
新增代码
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
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")
# 直接删除代码
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
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
nothing to commit, working tree clean

辛亏我们工作效率不高,才写了一行代码就发现不行了,要是你写了3天,一直都没有提交,该怎么删掉呢?你自己都忘了自己新增过哪些,有同学说,我可以 git diff xxx 一下,看看差别在删啊,那你肯定又要花3天时间删代码了,并且很大的概率还会改出bug。一周过去了,你怎么向你的老板交代呢?

Git 其实还为我们提供了更好的方式,我们可以使用 git checkout – [file]命令让工作区的文件回到最近一次 add 或 commit 时的状态。要注意 git checkout – [file]命令中的
很重要,切记不要省略,一旦省略,该命令就变为其他意思了,后面我们再说。示例如下:

# 
向ReadMe中新增⼀⾏代码
hyb@139-159-150-152:~/gitcode$ vim ReadMe 
hyb@139-159-150-152:~/gitcode$ cat ReadMe 
hello bit
hello git
hello world
hello version1
hello version2
hello version3
This piece of code is like shit  #新增代码 
# 恢复到上⼀次add 或commit
hyb@139-159-150-152:~/gitcode$ git checkout -- ReadMe
hyb@139-159-150-152:~/gitcode$ cat ReadMe 
hello bit
hello git
hello world
hello version1
hello version2
hello version3
  • 情况二:已经 add ,但没有commit
    add 后还是保存到了暂存区呢?怎么撤销
# 向ReadMe中新增⼀⾏代码
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
This piece of code is like shit  #
# add存⼊暂存区新增代码
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
Changes to be committed :
(use "git restore --staged <file>..." to unstage)
modified:   ReadMe

让我们来回忆一下学过的 git reset 回退命令,该命令如果使用 --mixed 参数,可以将暂存区的内容退回为指定的版本内容,但工作区文件保持不变。那我们就可以回退下暂存区的内容了

#--mixed 是默认参数,使用时可以省略
qcje139 - 159 - 150 - 152:~/ gitcode$ git reset HEAD ReadMe
Unstaged changes after reset :
M      ReadMe

用 git status 查看一下,发现现在暂存区是干净的,工作区有修改。

qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
Changes not staged for commit :(use "git add <file>..." to update what will be committed)(use "git restore <file>..." to discard changes in working directorymodified :
ReadMe
no changes added to commit(use "git add" and /or "git commit -a")

还记得如何丢弃工作区的修改吗?

hybe139-159-150-152:~/gitcode$ git checkout -- ReadMe
hyb@139-159-150-152:~/gitcode$ git status
On branch master
nothing to commit,working tree clean
hybe139-159-150-152:~/gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3

恢复了!

  • 情况三:已经 add ,并且也commit了

不要担心,我们可以 git reset --hardHEAD^回退到上一个版本!不过,这是有条件的,就是你还没有把自己的本地版本库推送到远程。还记得Git是分布式版本控制系统吗?我们后面会讲到远程版本库,一旦你推送到远程版本库,你就真的惨了

# 向ReadMe中新增⼀⾏代码
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
This piece of code is like shit  #新增代码
# 提交
qcj@139 - 159 - 150 - 152:~/ gitcode$ git add ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"test quash"
[master 5f71ae1] test quash
1 file changed, 1 insertion(+)
# 回退
qcj@139 - 159 - 150 - 152:~/ gitcode$ git reset --hard HEAD ^
HEAD is now at 144a3f8 add file
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3

1.3 删除文件

在 Git 中,删除也是一个修改操作,我们实战一下,如果要删除 file5 文件,怎么搞呢?如果你这样做了

qcj@139 - 159 - 150 - 152:~/ gitcode$ ls
file1  file2  file3  file4  file5  ReadMe
qcj@139 - 159 - 150 - 152:~/ gitcode$rm file5

但这样直接删除是没有用的,反而徒增烦恼,git status 命令会立刻告诉你哪些文件被删除了:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
Changes not staged for commit :(use "git add/rm <file>..." to update what will be committed)(use "git restore <file>..." to discard changes in working directory)deleted:
file5
no changes added to commit(use "git add" and /or "git commit -a")

此时,工作区和版本库就不一致了,要删文件,目前除了要删工作区的文件,还要清除版本库的文件。

⼀般走到这里,有两种可能:

  • 确实要从版本库中删除该文件
  • 不小心删错了
    对第二种情况,很明显误删,需要使用 git 来进行恢复,很简单,我们刚学过(删除也是修改)
hyb@139-159-150-152:~/gitcode$ git checkout -- file5hyb@139-159-150-152:~/gitcode$ lsfile1  file2  file3  file4  file5  ReadMe

对于第一种情况,很明显是没有删完,我们只删除了工作区的文件。这时就需要使用 gitrm 将文件从暂存区和工作区中删除,并且commit :

qcj@139 - 159 - 150 - 152:~/ gitcode$
git rm file5
rm 'file5'
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
Changes to be committed :
(use "git restore --staged <file>..." to unstage)
deleted:file5
qcj@139 - 159 - 150 - 152:~/ gitcode$git rmgit commit - m"deleted file5"
[master 5476bde] deleted file5
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 file5
qcj@139 - 159 - 150 - 152:~/ gitcode$ git status
On branch master
nothing to commit, working tree clean

现在,文件就从版本库中被删除了。

二. 分支管理

2.1 理解分支

本章开始介绍 Git 的杀手级功能之一(注意是之一,也就是后面还有之二,之三……):分支。分支就是科幻电影里面的平行宇宙,当你正在电脑前努力学习 C++ 的时候,另一个你正在另一个平行宇宙里努力学习 JAVA。

如果两个平行宇宙互不干扰,那对现在的你也没啥影响。不过,在某个时间点,两个平行宇宙合并了,结果,你既学会了 C++ 又学会了 JAVA!

在版本回退里,你已经知道,每次提交,Git都把它们串成一条时间线,这条时间线就可以理解为是个分支。截止到目前,只有一条时间线,在Git里,这个分支叫主分支,即master分支。

再来理解一下HEAD,HEAD 严格来说不是指向提交,而是指向master,master才是指向提交的,所以,HEAD 指向的就是当前分支。

每次提交,master分支都会向前移动一步,这样,随着你不断提交,master分支的线也越来越长,而HEAD只要一直指向master分支即可指向当前分支。

通过查看当前的版本库,我们也能清晰的理出思路:

qcj@139 - 159 - 150 - 152:~/ gitcode$ cat.git / HEAD
ref : refs / heads / master
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat.git / refs / heads / master
5476bdeb12510f7cd72ac4766db7988925ebd302

2.2 创建分支

Git 支持我们查看或创建其他分支,在这里我们来创建第一个自己的分支 dev ,对应的命令为:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch
* master
qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch dev
qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch
dev
* master

当我们创建新的分支后,Git 新建了一个指针叫 dev,*表示当前 HEAD 指向的分支是 master分支。另外,可以通过目录结构发现,新的 dev分支:

qcj@139 - 159 - 150 - 152:~/ gitcode$ ls.git / refs / heads /
dev  master
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat.git / refs / heads/*
5476bdeb12510f7cd72ac4766db7988925ebd302
5476bdeb12510f7cd72ac4766db7988925ebd302

发现目前 dev和 master指向同一个修改。并且也可以验证下 HEAD 目前是指向 master 的。

hyb@139-159-150-152:~/gitcode$ cat .git/HEADref: refs/heads/master

一张图总结:
在这里插入图片描述

2.3 切换分支

那如何切换到 dev分支下进行开发呢?使用 git checkout 命令即可完成切换,示例如下

qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout dev
Switched to branch 'dev'
qcj139 - 159 - 150 - 152 : ~/ gitcode$ git branch
* dev
master
qcj@139 - 159 - 150 - 152:~/ gitcode$ cat.git / HEAD
ref : refs / heads / dev


我们发现 HEAD 已经指向了 dev,就表示我们已经成功的切换到了 dev 上!

接下来,在 dev 分支下修改 ReadMe文件,新增一行内容,并进行一次提交操作:

qcj@139 - 159 - 150 - 152:~/ gitcode$ vim ReadMe
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
qcje139 - 159 - 150 - 152:~/ gitcode$ git add .
qcj@139 - 159 - 150 - 152:~/ gitcode$ git commit - m"modify ReadMe"
[dev 3740dce] modify ReadMe
1 file changed, l insertion(+)

现在,dev分支的工作完成,我们就可以切换回 master分支:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git checkout master
Switched to branch 'master
qcj@139 - 159 - 150 - 152:~/ gitcodes cat ReadMe
hello bit
hello git
hello world
hello version1
hello version2
hello version3

切换回 master 分支后,发现ReadMe文件中新增的内容不见了!!!赶紧再切回 dev看看

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

在 dev分支上,内容还在。为什么会出现这个现象呢?我们来看看 dev分支和 master分支指向,发现两者指向的提交是不一样的:

qcj@139 - 159 - 150 - 152:~/ gitcode$ cat.git / refs / heads / dev
bdaf528ffbb8e05aee34d37685408f0e315e31a4
qcj@139 - 159 - 150 - 152 : ~/ gitcode$ cat.git / refs / heads / master
5476bdeb12510f7cd72ac4766db7988925ebd302

看到这里就能明白了,因为我们是在dev分支上提交的,而master分支此刻的提交点并没有变,此时的状态如图如下所示。

当切换到 master分支之时,HEAD 就指向了 master,当然看不到提交了!

2.4 合并分支

为了在 master 主分支上能看到新的提交,就需要将 dev 分支合并到 master 分支,示例如下:

qcj139 - 159 - 150 - 152:~/ gitcode$ git branch
* dev
master
qcje139 - 159 - 150 - 152 : ~/ gitcode$ git checkout master
# 切换到 master 上进行合并
Switched to branch 'master'
qcje139 - 159 - 150 - 152:~/ gitcodes git merge dev #合并 dev 分支
Updating 16623e1..3740dce
Fast - forward
ReadMe1 +
l file changed, 1 insertion(+)
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

git merge 命令用于合并指定分支到当前分支。合并后,master就能看到dev分支提交的内容了。此时的状态如图如下所示。

Fast-forward 代表“快进模式”也就是直接把master指向dev的当前提交,所以合并速度非常快。当然,也不是每次合并都能 Fast-forward,我们后面会讲其他方式的合并。

2.5 删除分支

合并完成后,dev分支对于我们来说就没用了,那么dev分支就可以被删除掉,注意如果当前正处于某分支下,就不能删除当前分支,如:

qcj@139 - 159 - 150 - 152:~/ gitcode$ git branch
* dev
master
qcj@139 - 159 - 150 - 152:~/ gitcode$
git branch - d dev
error : Cannot delete branch 'dev' checked out at '/home/qcj/gitcode'

而可以在其他分支下删除当前分支,如:

qcje139 - 159 - 150 - 152:~/ gitcode$ git checkout master
Switched to branch 'master
qcje139 - 159 - 150 - 152 : ~/ gitcode$ git branch - d dev
Deleted branch dev(was bdaf528).
qcje139 - 159 - 150 - 152 : ~/ gitcode$ git branch
* master

此时的状态如图如下所示。

因为创建、合并和删除分支非常快,所以Git鼓励你使用分支完成某个任务,合并后再删掉分支,这和直接在master分支上工作效果是一样的,但过程更安全。

2.6 图文分析

上面的过程的 下面这一张图搞定!

后言

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

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

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

相关文章

Scheme语言的压力测试

Scheme语言的压力测试 引言 Scheme是一种广泛使用的函数式编程语言&#xff0c;它是Lisp语言家族的一员&#xff0c;以其简洁性和强大的表达能力而闻名。在现代软件开发中&#xff0c;施行压力测试是一项关键技术&#xff0c;旨在评估系统在高负载或极端情况下的表现。在这篇…

[特殊字符]Windows 11 安装 Git 图文教程(含详细配置说明)

Windows 11 安装 Git 图文教程(含详细配置说明) 本教程适用于 Git 新手,手把手教你如何在 Windows 11 上完整安装 Git 并正确配置,配图清晰,步骤明确,建议收藏! ✅ 第一步:下载 Git 安装包 访问官网:https://git-scm.com自动识别系统后点击下载或者直接前往:Git for …

简单以太网配置

display arp //查看路由器mac地址 交换机配置命令&#xff1a; system-view // 从用户视图进入系统视图 dis mac-address //查看mac地址表 路由器配置命令: system-view // 从用户视图进入系统视图 int GigabitEthernet 0/0/0 //进入G口 0/0/0 进入之后配置网关: ip addre…

【GPT入门】第25课 掌握 LangChain:链式调用的奥秘、特性与使用示例

【GPT入门】第25课 掌握 LangChain&#xff1a;链式调用的奥秘、特性与使用示例 语法解释各部分性质链式调用的性质调用方式注意事项 语法解释 你给出的代码 is_duplicated_chain (check_duplicated | model | parser) 运用了 LangChain 里的链式调用语法。在 LangChain 中&a…

二、vtkCommand的使用

一、概述 vtkCommand是VTK中的一个重要的类&#xff0c;用于处理事件和回调机制。它允许用户在特定事件发生时执行自定义的操作&#xff0c;例如在交互操作、数据更新或渲染过程中触发某些功能。 二、主要功能 1、事件处理&#xff1a;vtkCommand用于监听和处理VTK管线中的各…

配置集群-日志聚集操作

1.修改配置文件 <!-- 开启日志聚集功能 --> <property> <name>yarn.log-aggregation-enable</name> <value>true</value> </property> <!-- 设置日志聚集服务器地址 --> <property> <name>yarn.log.server.url&…

Linux系统上后门程序的原理细节,请仔细解释一下

在Linux系统上&#xff0c;后门程序通常通过隐蔽的方式绕过正常的安全机制&#xff0c;允许攻击者未经授权访问系统。以下是其工作原理的详细解释&#xff1a; 1. 隐蔽性 隐藏进程&#xff1a;后门程序常通过修改进程列表或使用rootkit技术隐藏自身&#xff0c;避免被ps、top…

华为ipd流程华为流程体系管理华为数字化转型流程数字化管理解决方案介绍81页精品PPT

华为流程体系最佳实践主要包括构建完善的流程框架&#xff0c;明确各层级流程要素与职责&#xff0c;梳理涵盖研发、采购、营销、服务、资产管理等多领域的流程&#xff0c;通过梳理业务场景和核心能力搭建差异化流程框架&#xff0c;采用自上而下与自下而上相结合的建模方法&a…

QT国产化系统软件开发

一、国产操作系统 1、鸿蒙HarmonyOS NEXT ‌核心架构‌ 采用自研鸿蒙内核&#xff0c;完全脱离Linux与AOSP代码&#xff0c;基于分布式架构实现跨设备资源虚拟化整合&#xff0c;支持动态调度多终端硬件能力‌。通过分布式软总线技术&#xff08;D-Bus&#xff09;实现低时延…

Oracle常见系统函数

一、字符类函数 1&#xff0c;ASCII(c)和CHR(i)字符串和ascii码互转换 SQL> select ascii(Z) ,ascii(H),ascii( A) from dual;ASCII(Z) ASCII(H) ASCII(A) ---------- ---------- ----------90 72 32SQL> select chr(90),chr(72),chr(65) from dual;C…

python pytorch tensorflow transforms 模型培训脚本

环境准备 https://www.doubao.com/thread/w5e26d6401c003bb2 执行培训脚本 import torch from torch.utils.data import Dataset, DataLoader from transformers import DistilBertTokenizer, DistilBertForSequenceClassification, AdamW import numpy as np# 自定义数据集类…

request库基础学习

requests安装 Windows &#xff1a;pip install requests mac &#xff1a; python3 -m pip install requests requests模块常用方法 方法含义requests.get()发起get请求requests.post()发起post请求requests.put()发起put请求requests.delete()发起delete请求requests.sess…

Redis客户端Jedis、Lettuce 和 Redisson优缺点总结

https://developer.huawei.com/consumer/cn/blog/topic/03825550899620047 Redis 官方推荐的 Java 客户端有Jedis、Lettuce 和 Redisson。本文总结这些客服端的优缺点 1. Jedis Jedis 是老牌的 Redis 的 Java 实现客户端&#xff0c;提供了比较全面的 Redis 命令的支持&#…

在 Spring Boot 中调用 AnythingLLM 的发消息接口

整体逻辑: 自建系统的web UI界面调用接口: 1.SpringBoot接口&#xff1a;/anything/chatMessageAnything 2.调用anythingLLM - 调用知识库deepseek r1 . Windows Installation ~ AnythingLLMhttps://docs.anythingllm.com/installation-desktop/windows http://localhost:3…

kubectl describe pod 命令以及输出详情讲解

kubectl describe pod 命令格式 kubectl describe pod <pod-name> -n <namespace><pod-name>&#xff1a;Pod 的名称。 -n <namespace>&#xff1a;指定命名空间&#xff0c;默认是当前命名空间。 controlplane ~ ✖ kubectl describe pod newpods-d…

Python生成和安装requirements.txt

概述 看到别的大佬项目中&#xff0c;requirements.txt文件&#xff0c;里面包含了所需要的依赖及版本&#xff0c;方便项目管理和安装。 生成 requirements.txt 文件 pip3 freeze > requirements.txt生成的依赖包有点多&#xff0c;感觉可以根据自己需要整理。 安装req…

WebGL学习2

WebGL&#xff08;Web Graphics Library&#xff09;是一种基于 OpenGL ES 2.0 的 JavaScript API&#xff0c;用于在网页上实现高性能的 3D 图形渲染。 1. 初始化 WebGL 上下文 在使用 WebGL 之前&#xff0c;需要获取<canvas>元素并创建 WebGL 上下文。 // 获取canv…

零知识证明:区块链隐私保护的变革力量

&#x1f9d1; 博主简介&#xff1a;CSDN博客专家&#xff0c;历代文学网&#xff08;PC端可以访问&#xff1a;https://literature.sinhy.com/#/literature?__c1000&#xff0c;移动端可微信小程序搜索“历代文学”&#xff09;总架构师&#xff0c;15年工作经验&#xff0c;…

【java】集合的基本使用

集合是 Java 中用来存储一组对象的容器。与数组相比&#xff0c;集合更加灵活和强大&#xff0c;支持动态增删元素、自动扩容、多种数据结构等特性。下面我会用通俗易懂的语言解释集合的基本使用。 1. 什么是集合&#xff1f; 集合就像是一个“容器”&#xff0c;可以用来装很多…

WPF-实现按钮的动态变化

MVVM 模式基础 视图模型&#xff08;ViewModel&#xff09;&#xff1a;MainViewModel类作为视图模型&#xff0c;封装了与视图相关的属性和命令。它实现了INotifyPropertyChanged接口&#xff0c;当属性值发生改变时&#xff0c;通过OnPropertyChanged方法通知视图进行更新&am…