【Git版本控制 01】基本操作

目录

一、初始配置

二、添加文件

三、查看日志

四、修改文件

五、版本回退

六、撤销修改

七、删除文件


一、初始配置

Git版本控制器:记录每次的修改以及版本迭代的一个管理系统。

# 初始化本地仓库:git init(base) [root@localhost gitcode]# git init
重新初始化现存的 Git 版本库于 /root/gitee/gitcode/.git/
(base) [root@localhost gitcode]# ls -a
.  ..  .git
(base) [root@localhost gitcode]# tree .git
.git
├── branches
├── config
├── description
├── HEAD
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   ├── post-update.sample
│   ├── pre-applypatch.sample
│   ├── pre-commit.sample
│   ├── prepare-commit-msg.sample
│   ├── pre-push.sample
│   ├── pre-rebase.sample
│   └── update.sample
├── info
│   └── exclude
├── objects
│   ├── info
│   └── pack
└── refs├── heads└── tags9 directories, 13 files
(base) [root@localhost gitcode]# 
# 查看本地仓库配置(base) [root@localhost gitcode]# git config -l
push.default=matching
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
(base) [root@localhost gitcode]#
# 配置当前仓库(base) [root@localhost gitcode]# git config user.name "ljc"
(base) [root@localhost gitcode]# git config user.email "1210451061@qq.com"
(base) [root@localhost gitcode]# git config -l
push.default=matching
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
user.name=ljc
user.email=1210451061@qq.com
(base) [root@localhost gitcode]# 
# 删除当前仓库配置(base) [root@localhost gitcode]# git config --unset user.name
(base) [root@localhost gitcode]# git config --unset user.email
(base) [root@localhost gitcode]# git config -l
push.default=matching
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
(base) [root@localhost gitcode]#
# 配置当前机器的全部仓库(base) [root@localhost gitcode]# git config --global user.name "ljc"
(base) [root@localhost gitcode]# git config --global user.email "1210451061@qq.com"
(base) [root@localhost gitcode]# git config -l
push.default=matching
user.name=ljc
user.email=1210451061@qq.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true# 删除当前机器的全部仓库配置(base) [root@localhost gitcode]# git config --global --unset user.name
(base) [root@localhost gitcode]# git config --global --unset user.email
(base) [root@localhost gitcode]# git config -l
push.default=matching
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
(base) [root@localhost gitcode]#

二、添加文件

⼯作区:是在电脑上你要写代码或⽂件的⽬录。

暂存区:英⽂叫 stage 或 index 。⼀般存放在 .git ⽬录下的 index ⽂件(.git/index)中,我们把暂存区有时也叫作索引(index)。

版本库:⼜名仓库,英⽂名 repository 。⼯作区有⼀个隐藏⽬录 .git ,它不算⼯作区,⽽是 Git 的版本库。这个版本库⾥⾯的所有⽂件都可以被 Git 管理起来,每个⽂件的修改、删除,Git 都能跟踪,以便任何时刻都可以追踪历史,或者在将来某个时刻可以“还原”。

  1. 创建 Git 版本库时,Git会为我们⾃动创建⼀个唯⼀的 master 分⽀,以及指向 master 的⼀个指针叫 HEAD。
  2. 对⼯作区修改(或新增)的⽂件执⾏ git add 命令时,暂存区⽬录树的⽂件索引会被更新。
  3. 执⾏提交操作 git commit 时,master 分⽀会做相应的更新,可以简单理解为暂存区的⽬录树才会被真正写到版本库中。
# 添加一个文件(base) [root@localhost gitcode]# ls
(base) [root@localhost gitcode]# touch file1
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git(base) [root@localhost gitcode]# git add file1
(base) [root@localhost gitcode]# git commit -m "Add first file"
[master(根提交) fc3a350] Add first file1 file changed, 2 insertions(+)create mode 100644 file1
(base) [root@localhost gitcode]#
# 添加多个文件(base) [root@localhost gitcode]# touch file2 file3 file4
(base) [root@localhost gitcode]# git add .
(base) [root@localhost gitcode]# git commit -m "Add three files"
[master f2e9210] Add three files3 files changed, 0 insertions(+), 0 deletions(-)create mode 100644 file2create mode 100644 file3create mode 100644 file4
(base) [root@localhost gitcode]# git log
commit f2e92108d0fe7ec01a6c49d1372e4907cac6d96b
Author: ljc <1210451061@qq.com>
Date:   Wed Feb 7 05:13:08 2024 +0800Add three filescommit fc3a3507b30d2f4374a71245a034e00f94ea8363
Author: ljc <1210451061@qq.com>
Date:   Wed Feb 7 05:11:56 2024 +0800Add first file
(base) [root@localhost gitcode]#

三、查看日志

# git log 命令显⽰从最近到最远的提交⽇志
# 加上 --pretty=online 参数会将日志简洁显示(base) [root@localhost gitcode]# git log --pretty=oneline
f2e92108d0fe7ec01a6c49d1372e4907cac6d96b Add three files
fc3a3507b30d2f4374a71245a034e00f94ea8363 Add first file
(base) [root@localhost gitcode]## 通过 git log 可以看到的长字符串是每次提交的commit id(版本号),是一个哈希值
# 查看 .git(base) [root@localhost gitcode]# tree .git
.git
├── branches
├── COMMIT_EDITMSG
├── config
├── description
├── HEAD
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   ├── post-update.sample
│   ├── pre-applypatch.sample
│   ├── pre-commit.sample
│   ├── prepare-commit-msg.sample
│   ├── pre-push.sample
│   ├── pre-rebase.sample
│   └── update.sample
├── index
├── info
│   └── exclude
├── logs
│   ├── HEAD
│   └── refs
│       └── heads
│           └── master
├── objects
│   ├── 2c
│   │   └── 0f71d14208bc896178ce4eb92870c659c04202
│   ├── 74
│   │   └── cbb01783907aa0807236331230386d5e1241cf
│   ├── 7f
│   │   └── 112b196b963ff72675febdbb97da5204f9497e
│   ├── e6
│   │   └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
│   ├── f2
│   │   └── e92108d0fe7ec01a6c49d1372e4907cac6d96b
│   ├── fc
│   │   └── 3a3507b30d2f4374a71245a034e00f94ea8363
│   ├── info
│   └── pack
└── refs├── heads│   └── master└── tags18 directories, 24 files
(base) [root@localhost gitcode]#
# index 是暂存区,add 后的内容会添加进缓存区
# HEAD 是默认指向 master 分支的指针
# 默认的 master 保存的就是最新的 commit id(base) [root@localhost gitcode]# cat .git/HEAD
ref: refs/heads/master
(base) [root@localhost gitcode]# cat .git/refs/heads/master
f2e92108d0fe7ec01a6c49d1372e4907cac6d96b
(base) [root@localhost gitcode]# # objects 为Git的对象库,里面包含了创建的各个版本的对象及内容。
# 当执行 git add 的时候,暂存区的对象树被更新,
# 同时工作区修改(或新增)的文件内容被写入到对象库中的一个新的对象中,
# 就位于 ./git/objects 目录下(base) [root@localhost gitcode]# ls .git/objects/
2c  74  7f  e6  f2  fc  info  pack# 查找 object 要将 commit id 分为两部分,前2位是目录名称,后38位文件名称
# 使用 git cat-file 查看版本库对象的内容
# <类型> 可以是其中之一:blob、tree、commit、tag
#    -t                    显示对象类型
#    -s                    显示对象大小
#    -e                    当没有错误时退出并返回零
#    -p                    美观地打印对象的内容
#    --textconv            对于数据(blob)对象,对其内容执行 textconv
#    --batch               显示从标准输入提供的对象的信息和内容
#    --batch-check         显示从标准输入提供的对象的信息(base) [root@localhost gitcode]# git cat-file -p f2e92108d0fe7ec01a6c49d1372e4907cac6d96b
tree 74cbb01783907aa0807236331230386d5e1241cf
parent fc3a3507b30d2f4374a71245a034e00f94ea8363
author ljc <1210451061@qq.com> 1707253988 +0800
committer ljc <1210451061@qq.com> 1707253988 +0800Add three files
(base) [root@localhost gitcode]# git cat-file -p 74cbb01783907aa0807236331230386d5e1241cf
100644 blob 7f112b196b963ff72675febdbb97da5204f9497e    file1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    file2
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    file3
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    file4
(base) [root@localhost gitcode]# # 查看 file1 对应的 commit id[root@localhost gitcode]# git cat-file -p 7f112b196b963ff72675febdbb97da5204f9497e
hello git(base) [root@localhost gitcode]# 

四、修改文件

Git版本控制器的本质:跟踪并管理文件的修改,而非文件本身。

# 对file1文件内容进行修改,此时工作区和暂存区的文件版本不一致
# 用 git status 查看在你上次提交之后是否有对文件进行再次修改(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
(base) [root@localhost gitcode]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#       修改:      file1
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
(base) [root@localhost gitcode]# 
# git diff [file] 查看暂存区和工作区文件的具体差异
# git diff HEAD -- [file] 查看版本库和工作区文件的具体差异(base) [root@localhost gitcode]# git diff file1
diff --git a/file1 b/file1
index 7f112b1..05fe86c 100644
--- a/file1
+++ b/file1
@@ -1,2 +1,2 @@hello git
-
+hello world
(base) [root@localhost gitcode]# git diff HEAD -- file1
diff --git a/file1 b/file1
index 7f112b1..05fe86c 100644
--- a/file1
+++ b/file1
@@ -1,2 +1,2 @@hello git
-
+hello world
(base) [root@localhost gitcode]# 
(base) [root@localhost gitcode]# git add file1
(base) [root@localhost gitcode]# git status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#       修改:      file1
#
(base) [root@localhost gitcode]# git commit -m "modify: file1"
[master 7df1e32] modify: file11 file changed, 1 insertion(+), 1 deletion(-)
(base) [root@localhost gitcode]# git status
# 位于分支 master
无文件要提交,干净的工作区
(base) [root@localhost gitcode]# 

五、版本回退

Git将所有提交过的版本串成一条时间线,若只有一条时间线,则这个分支就是主分支,即master分支。

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

当进行版本回退的时候,只需要改变master指针的指向,就完成了版本回退,非常高效。

# 给 file1 新增 vertion1 和 vertion2 两个版本并分别提交(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
(base) [root@localhost gitcode]# git add file1
(base) [root@localhost gitcode]# git commit -m "modify: add vertion1"
[master 167def0] modify: add vertion11 file changed, 1 insertion(+)
(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
(base) [root@localhost gitcode]# git add file1
(base) [root@localhost gitcode]# git commit -m "modigy: add vertion2"
[master c31b56a] modigy: add vertion21 file changed, 1 insertion(+)
(base) [root@localhost gitcode]#
# 通过 git reset 回退版本
# 在进行版本回退之前,通常先用 git log 查看历史版本(base) [root@localhost gitcode]# git log --pretty=oneline
c31b56a87a6387873d7db9a16f7d1c81b4b2339e modigy: add vertion2
167def04692b8f6fa68cc835f41a81584ca31b7e modify: add vertion1
7df1e322e9d267964f51e91dac900bb1a77f171d modify: file1
f2e92108d0fe7ec01a6c49d1372e4907cac6d96b Add three files
fc3a3507b30d2f4374a71245a034e00f94ea8363 Add first file
(base) [root@localhost gitcode]# git reset 167def04692b8f6fa68cc835f41a81584ca31b7e
重置后撤出暂存区的变更:
M       file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
(base) [root@localhost gitcode]# git reset --hard 167def04692b8f6fa68cc835f41a81584ca31b7e
HEAD 现在位于 167def0 modify: add vertion1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
(base) [root@localhost gitcode]# # 由上可见,直接使用 git reset 回退版本,工作区的文件内容并未修改
# 因为回退版本的完整命令格式为:git reset [--soft | --mixed | --hard] [HEAD]# 不同的参数代表不同的回退方式:
#     --soft  对于工作区和暂存区的内容都不变,只将版本库回退到指定版本
#     --mixed 对于工作区的内容不变,暂存区和版本库回退到指定版本,默认参数
#     --hard  对于工作区、暂存区和版本库都回退到指定版本# [HEAD] 说明:
#     1. 可直接写成 commid id,表示特定的版本
#     2. HEAD 表示当前版本
#     3. HEAD^ 表示上一个版本
#     4. HEAD^^ 表示上上个版本
#     5. ... 依此类推
# 当我回退到 vertion1 之后后悔,我想再回到 vertion2 怎么办?
# 1. 直接用 vertion2 的 commit id 进行回退
# 2. 如果找不到 vertion2 的 commit id 了,通过 git reflog 查看本地的历史命令,
#    可以得到 vertion2 的部分 commit id,也可直接回退(base) [root@localhost gitcode]# git reflog
167def0 HEAD@{0}: reset: moving to 167def04692b8f6fa68cc835f41a81584ca31b7e
c31b56a HEAD@{1}: commit: modigy: add vertion2
167def0 HEAD@{2}: commit: modify: add vertion1
7df1e32 HEAD@{3}: reset: moving to 7df1e322e9d267964f51e91dac900bb1a77f171d
3d8c2fe HEAD@{4}: commit: modify: add vertion1
7df1e32 HEAD@{5}: commit: modify: file1
f2e9210 HEAD@{6}: commit: Add three files
fc3a350 HEAD@{7}: commit (initial): Add first file
(base) [root@localhost gitcode]# git reset --hard c31b56a
HEAD 现在位于 c31b56a modigy: add vertion2
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
(base) [root@localhost gitcode]#

六、撤销修改

版本回退是我们已经提交了版本,更新了版本库之后再进行回退操作,但是如果我们在开发过程中,新写了很多代码但是没有 add ,这时候忽然发现自己写的代码全是屎山代码,想要回到新增代码前的版本,该怎么做呢?是先提交更新版本再版本回退吗?

上述方式虽然也行,但是太麻烦了,可以直接用 git checkout -- [file] 命令让工作区的文件回到最近一次 add 和 commit 时的状态。

(base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
too much shit code!!!
(base) [root@localhost gitcode]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#       修改:      file1
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
(base) [root@localhost gitcode]# git checkout -- file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
(base) [root@localhost gitcode]## 如果代码已经 add 但还没 commit 呢?怎么处理?
# 方法1:先 git reset [file] 再 git checkout --[file]
# 方法2:直接 git reset --hard [file](base) [root@localhost gitcode]# vim file1
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
too much shit code
(base) [root@localhost gitcode]# git add file1
(base) [root@localhost gitcode]# git status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#       修改:      file1
#
(base) [root@localhost gitcode]# git log --pretty=oneline
c31b56a87a6387873d7db9a16f7d1c81b4b2339e modigy: add vertion2
167def04692b8f6fa68cc835f41a81584ca31b7e modify: add vertion1
7df1e322e9d267964f51e91dac900bb1a77f171d modify: file1
f2e92108d0fe7ec01a6c49d1372e4907cac6d96b Add three files
fc3a3507b30d2f4374a71245a034e00f94ea8363 Add first file
(base) [root@localhost gitcode]# git reset --hard c31b56a87a6387873d7db9a16f7d1c81b4b2339e
HEAD 现在位于 c31b56a modigy: add vertion2
(base) [root@localhost gitcode]# cat file1
hello git
hello world
add vertion1
add vertion2
(base) [root@localhost gitcode]# 

七、删除文件

删除的本质也是修改,如果我们在工作区用 rm 命令删除了一个文件,那么可能是两种原因:

  1. 误删
  2. 确定要删除该文件
# 如果是误删,那么我们需要取消删除操作,也就是撤销修改操作。
# 如果是确认要删除该文件,那么通过 rm 删除之后,工作区和暂存区、版本库就不一致了。
# 我们该如何处理呢?
# 我们需要先将删除后的工作区更新到暂存区,再将暂存区提交到版本库。(base) [root@localhost gitcode]# ls
file1  file2  file3  file4
(base) [root@localhost gitcode]# rm -rf file4
(base) [root@localhost gitcode]# ls
file1  file2  file3
(base) [root@localhost gitcode]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add/rm <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#       删除:      file4
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
(base) [root@localhost gitcode]# git add .
warning: 您在运行 'git add' 时没有指定 '-A (--all)' 或 '--ignore-removal',
针对其中本地移除路径的行为将在 Git 2.0 版本库发生变化。
像本地工作区移除的路径 'file4'
在此版本的 Git 中被忽略。* 'git add --ignore-removal <pathspec>',是当前版本的默认操作,忽略您本地工作区中移除的文件。* 'git add --all <pathspec>' 将让您同时对删除操作进行记录。运行 'git status' 来检查您本地工作区中移除的路径。(base) [root@localhost gitcode]# git add --all file4
(base) [root@localhost gitcode]# git commit -m "delete file4"
[master 0f28717] delete file41 file changed, 0 insertions(+), 0 deletions(-)delete mode 100644 file4
(base) [root@localhost gitcode]# git status
# 位于分支 master
无文件要提交,干净的工作区
(base) [root@localhost gitcode]# ls
file1  file2  file3
(base) [root@localhost gitcode]# # 由上可得,我们需要处理不一致问题,也就是将删除后的新版本再次提交到版本库
# 我们可以也通过 git rm 进行文件删除,这样直接就删除了工作区和暂存区的文件
# 我们只需要接着 git commit -m 更新删除后的版本就行了(base) [root@localhost gitcode]# ls
file1  file2  file3
(base) [root@localhost gitcode]# git rm file3
rm 'file3'
(base) [root@localhost gitcode]# ls
file1  file2
(base) [root@localhost gitcode]# git status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#       删除:      file3
#
(base) [root@localhost gitcode]# git commit -m "delete file3"
[master 84b615b] delete file31 file changed, 0 insertions(+), 0 deletions(-)delete mode 100644 file3
(base) [root@localhost gitcode]#

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

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

相关文章

NLP_语言模型的雏形 N-Gram 模型

文章目录 N-Gram 模型1.将给定的文本分割成连续的N个词的组合(N-Gram)2.统计每个N-Gram在文本中出现的次数&#xff0c;也就是词频3.为了得到一个词在给定上下文中出现的概率&#xff0c;我们可以利用条件概率公式计算。具体来讲&#xff0c;就是计算给定前N-1个词时&#xff0…

ChatPromptTemplate和AI Message的用法

ChatPromptTemplate的用法 用法1&#xff1a; from langchain.chains import LLMChain from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import ChatPromptTemplate from langchain_community.tools.tavily_search import TavilySear…

STM32 微控制器应用领域

STM32 微控制器在多个领域有广泛应用&#xff0c;具体如下&#xff1a; 工业自动化&#xff1a;STM32 在工厂自动化、机器人控制、传感器接口和数据采集等方面具有出色的性能和可靠性&#xff0c;有助于实现高效的工业自动化系统。消费电子&#xff1a;STM32 适用于智能手机、…

阿里 EasyExcel 表头国际化

实体类字段使用EasyExcel提供的注解ExcelProperty&#xff0c;value 值写成占位符形式 &#xff0c;匹配 i18n 文件里面的编码。 如&#xff1a; /*** 仓库名称*/ ExcelProperty("{warehouse.record.warehouseName}") private String warehouseName;占位符解析器 A…

《电子芯片的夜晚》

《电子芯片的夜晚》 在这个寂静的城市中&#xff0c;有一位名叫小明的程序员。他不同寻常&#xff0c;因为他有一项神奇的技能——他能够让电子芯片们说出自己的故事。 一天&#xff0c;小明收到了一块别具灵性的电子芯片&#xff0c;传说这块芯片能够在夜晚让设备们复活&…

笔记---dp---数字三角形模型

所谓数字三角形模型&#xff0c;即是从数字三角形这一题衍生出来的 题目为经典题目&#xff0c;不再赘述&#xff0c;此笔记根据AcWing算法提高课来进行对数字三角形模型衍生例题的记录 题目关系如下&#xff08;见AcWing里的AcSaber&#xff09;&#xff1a; AcWing.1015.摘…

哪些软件可以提供更好的协同办公体验?

协同办公软件的选择取决于您的具体需求&#xff0c;包括团队规模、工作流程、预算以及所需的特定功能。根据搜索结果&#xff0c;这里有一些被推荐的协同办公软件&#xff0c;它们在不同的领域提供了良好的协同体验&#xff1a; 一、文档协同&#xff1a; 1.Pixso&#xff1a;这…

微信小程序(三十八)滚动容器

注释很详细&#xff0c;直接上代码 上一篇 新增内容&#xff1a; 1.滚动触底事件 2.下拉刷新事件 源码&#xff1a; index.wxml <view class"Area"> <!-- scroll-y 垂直滚动refresher-enabled 允许刷新bindrefresherrefresh 绑定刷新作用函数bindscrollto…

单片机无线发射的原理剖析

目录 一、EV1527编码格式 二、OOK&ASK的简单了解 三、433MHZ 四、单片机的地址ID 五、基于STC15W104单片机实现无线通信 无线发射主要运用到了三个知识点&#xff1a;EV1527格式&#xff1b;OOk&#xff1b;433MHZ。下面我们来分别阐述&#xff1a; EV1527是数据的编…

【算法题】92. 反转链表 II

题目 给你单链表的头指针 head 和两个整数 left 和 right &#xff0c;其中 left < right 。请你反转从位置 left 到位置 right 的链表节点&#xff0c;返回 反转后的链表 。 示例 1&#xff1a; 输入&#xff1a;head [1,2,3,4,5], left 2, right 4 输出&#xff1a;[…

Android 9.0 禁用adb reboot recovery命令实现正常重启功能

1.前言 在9.0的系统rom定制化开发中,在定制recovery模块的时候,由于产品开发需要要求禁用recovery的相关功能,比如在通过adb命令的 adb reboot recovery的方式进入recovery也需要实现禁用,所以就需要了解相关进入recovery流程来禁用该功能 2.禁用adb reboot recovery命…

【力扣 67】二进制求和 C++题解(位运算+模拟+字符串+位集合)

给你两个二进制字符串 a 和 b &#xff0c;以二进制字符串的形式返回它们的和。 示例 1&#xff1a; 输入:a “11”, b “1” 输出&#xff1a;“100” 示例 2&#xff1a; 输入&#xff1a;a “1010”, b “1011” 输出&#xff1a;“10101” 提示&#xff1a; 1 <…

网神 SecGate 3600 防火墙 route_ispinfo_import_save 文件上传漏洞

免责声明&#xff1a;文章来源互联网收集整理&#xff0c;请勿利用文章内的相关技术从事非法测试&#xff0c;由于传播、利用此文所提供的信息或者工具而造成的任何直接或者间接的后果及损失&#xff0c;均由使用者本人负责&#xff0c;所产生的一切不良后果与文章作者无关。该…

Golang 基础 Go Modules包管理

Golang 基础 Go Modules包管理 在 Go 项目开发中&#xff0c;依赖包管理是一个非常重要的内容&#xff0c;依赖包处理不好&#xff0c;就会导致编译失败&#xff0c;本文将系统介绍下 Go 的依赖包管理工具。 我会首先介绍下 Go 依赖包管理工具的历史&#xff0c;并详细介绍下…

LeetCode动态规划的解题思路

动态规划 动态规划&#xff0c;其实就是找规律&#xff0c;总结公式/方程。 动态规划&#xff0c;类似于数学归纳法。 关键的思想在「自底向上」和「空间换时间」。 动态规划&#xff0c;可以使用一维数组&#xff0c;有时也会用到二维数组。 应用场景 “动态规划”可以用于…

idea2023创建spring项目无法选择Java8

idea2023创建spring项目无法选择Java8 今天下载了新版的idea 2023.3.2&#xff0c;但是在创建springboot项目的时候只能选择Java17和Java21&#xff0c;没法选择其他的版本。 使用下面阿里云的地址替换Server URL中的start.spring.io的地址即可 https://start.aliyun.com/替…

C#调用WechatOCR.exe实现本地OCR文字识别

最近遇到一个需求&#xff1a;有大量的扫描件需要还原为可编辑的文本&#xff0c;很显然需要用到图片OCR识别为文字技术。本来以为这个技术很普遍的&#xff0c;结果用了几个开源库&#xff0c;效果不理想。后来&#xff0c;用了取巧的方法&#xff0c;直接使用了WX的OCR识别模…

Linux大集合

Linux Linux是什么&#xff1f; Linux是一套免费使用和自由传播的类Unix操作系统&#xff0c;是一个基于POSIX和UNIX的多用户、多任务、 支持多线程和多CPU的操作系统。它能运行主要的UNIX工具软件、应用程序和网络协议。它支持32位和 64位硬件。 Linux内核 是一个Linux系统…

可达鸭二月月赛——入门赛第四场T3题解

姓名 王胤皓 AC 记录 题目&#xff1a; 思路 用数组进行操作太难&#xff0c;而这些操作可以再 STL 中的 vector 容器&#xff0c;有 insert 和 erase 函数&#xff0c;所以非常方便。 vector 下标从 0 0 0 开始&#xff0c;所以所有操作都要 − 1 -1 −1。 操作 1 1 1 …

Redis的数据类型Hash使用场景实战

Redis的数据类型Hash使用场景 常见面试题&#xff1a;redis在你们项目中是怎么用的&#xff0c;除了String数据类型还使用什么数据类型&#xff1f; 怎么保证缓存和数据一致性等问题… Hash模型使用场景 知识回顾&#xff1a; redisTemplate.opsForHash() 方法是 Redis 的 …