-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
376 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# ***Git应用*** | ||
|
||
**1.** 方式一:使用git reset --hard HEAD 把工作区和暂存区都恢复到最后一次提交的状态,所有未提交的修改都会被丢弃。由于--hard参数会强制覆盖工作区的修改,使用时需考虑考虑。 | ||
|
||
![图片1](./images/图1.png) | ||
|
||
方式二:使用git checkout -- <文件名> 这将把指定文件恢复到最后一次提交的状态。 | ||
|
||
![图片2](./images/图2.png) | ||
|
||
**2.** 不修改历史记录:git reset --soft <commit_hash> 将 HEAD 指针移动到指定的提交,但是不会更改工作目录和暂存区的内容。 | ||
|
||
![图片3](./images/图3.png) | ||
|
||
修改历史记录:git reset --hard <commit_hash>:将 HEAD 指针移动到指定的提交,并重置工作目录和暂存区,使其与指定提交的状态完全一致。这会完全丢弃从指定提交之后的所有更改,并且无法恢复。 | ||
|
||
![图片4](./images/图4.png) | ||
|
||
**3.** 方式一:使用rebase命令,将一系列提交从一个分支上“复制”并“粘贴”到另一个分支上。 | ||
|
||
git checkout feature-branch | ||
|
||
git rebase master | ||
|
||
git checkout master | ||
|
||
git merge feature-branch | ||
|
||
![图片5](./images/图5.png) | ||
|
||
方式二:使用 cherry-pick`命令合并特定提交,将某个分支上的特定提交合并到其他分支。 | ||
|
||
git checkout master | ||
|
||
git cherry-pick <commit-hash> | ||
|
||
![图片6](./images/图6.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ***学习总结*** | ||
|
||
**1.** 这门课程开始,我们根据教程学会了双系统ubuntu的安装,并解决了在安装和配置系统时所遇到的各种问题;此外,ubuntu的使用与windows有很大的差别,需要去适应各种操作。 | ||
|
||
**2.** 课程介绍了Linux系统架构和命令行环境的强大功能,通过学习,我掌握了许多常用的命令并学会了数据整理的基本方法和技巧,了解了正则运算的基本使用。 | ||
|
||
**3.** 理解了CMake的基本概念和工作原理,掌握了CMake的基本命令,如cmake、make等,以及它们的基本用法。学会了如何编写基本CMakeLists.txt文件。 理解了Catkin工作空间的概念和结构,了解了Catkin构建系统的工作流程,即使用catkin_make或catkin build命令编译整个工作空间。 | ||
|
||
**4.** Git是一款分布式版本控制系统,在多人协作的项目开发中发挥着重要作用。在课程中学习了如何在一个新建的目录下创建Git仓库和克隆github仓库。掌握了git add命令,用于将修改的文件添加到暂存区;git commit命令将暂存区的文件提交到仓库,并附上提交说明;git log命令,用于查看提交历史记录。学习了如何创建分支以及如何合并分支到主分支的方法。并最终用git push的相关命令,用于将本地修改推送到远程仓库或从远程仓库拉取最新代码。 | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
git 学习总结 | ||
|
||
1.连接github | ||
配置个人的用户名称和电子邮件地址,: | ||
git config --global user.name "用户名" | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
~~很庆幸自己有充分的计算机基础,可以不至于被折磨地太惨~~ | ||
其实就现在来看,学到现在,最重要的东西大概就是要有着和计算机的思维。 | ||
|
||
~~虽然说得很抽象~~,但是其实在计算机上面的东西都是大同小异的。都是最基础的逻辑门和相似的设计语言构成了这个庞大的网。就像是编程语言和编程语言之间也有相似之处一样。这让我们只要理解了其中的一种语言,其他语言的学习成本就会直线下降。对于计算机只要理解了部份程序的设计语言,也就会降低学习其他程序的学习成本 | ||
#### 关于Linux | ||
安装Linux是一波三折的(修了一次引导表,后面还在不断地变换方案)。 | ||
并且在安装好Linux之后就要开始学会体会命令行的力量(大雾)~~(但是近乎无限的权限真的很爽)~~ | ||
#### 关于vim | ||
年少不知vim宝,错吧text editor当成宝 | ||
vim如果熟练之后真的好用 | ||
#### 关于 ROS | ||
只要挂了梯子安装起来还是很轻松的。 | ||
除这个之外鱼香ROS还是很好用的) | ||
#### 关于git | ||
某种意义上来说第一次接触项目管理,之前还很难理解是怎么实现的。 | ||
现在明白了,能搞出这套体系的人是真的nb(大雾) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
1. 若你已经修改了部分文件、并且将其中的一部分加入了暂存区,应该如何回退这些修改,恢复到修改前最后一次提交的状态?给出至少两种不同的方式 | ||
ans:我们可以使用 | ||
`git restore --staged .` | ||
`git checkout .` | ||
|
||
或者 | ||
|
||
`git reset HEAD <file> .` | ||
`git checkout .` | ||
参考: | ||
![图片](./image/q113.jpg) | ||
![图片](./image/q12.jpg) | ||
|
||
2. 若你已经提交了一个新版本,需要回退该版本,应该如何操作?分别给出不修改历史或修改历史的至少两种不同的方式 | ||
ans: | ||
不修改历史(?):首先用 | ||
`git log` | ||
查找commit号 | ||
![图片](./image/qg.jpg) | ||
然后用基于这个版本号新建一个分支,并推送 | ||
``` | ||
git branch <new_branch_name> <commit_number> | ||
git push <remote> <new_branch_name> | ||
git checkout <target_branch_name> | ||
``` | ||
修改分支: | ||
``` | ||
git reflog | ||
git reset --hard commit_id | ||
git push -f | ||
``` | ||
![图片](./image/q21.jpg) | ||
![图片](./image/q22.jpg) | ||
参考: | ||
3. 我们已经知道了合并分支可以使用 merge,但这不是唯一的方法,给出至少两种不同的合并分支的方式 | ||
ans:第一个 | ||
``` | ||
git rebase <target_feature> | ||
``` | ||
第二个:cherry-pick | ||
``` | ||
git cherry-pick <commithash> | ||
``` | ||
参考: | ||
![图片](./image/q31.jpg) | ||
![图片](./image/q32.jpg) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Final Project | ||
|
||
## 回退修改 | ||
|
||
1. 使用```restore```命令 | ||
|
||
![Task1-1](images/task1-1.png) | ||
|
||
2. 使用```checkout```命令 | ||
|
||
![Task1-2](images/task1-2.png) | ||
|
||
## 回退版本 | ||
|
||
假设我们已经提交的**bd5f5c**是我们想要撤回的 | ||
|
||
![Task2-0](images/task2-0.png) | ||
|
||
1. 使用```revert```命令 | ||
|
||
![Task2-2](images/task2-1.png) | ||
|
||
2. 使用```reset```命令 | ||
|
||
![Task2-3](images/task2-2.png) | ||
|
||
> [!NOTE] | ||
> | ||
> 需要注意的是: | ||
> | ||
> ```revert```会新建一个提交将之前的操作反转过来 | ||
> ```reset```则是直接将之前的提交丢弃掉 | ||
> | ||
> ```revert```适用于之前的提交已经push的情况,```reset```适用于之前的提交还在本地,当然本地也可以使用```revert``` | ||
## 合并分支 | ||
|
||
1. 使用```rebase```命令 | ||
|
||
![Task3-1](images/task3-1.png) | ||
|
||
2. 使用```cherry-pick```命令 | ||
|
||
![Task3-2](images/task3-2.png) | ||
|
||
3. 当然,最常用的还是```merge```命令 | ||
|
||
![Task3-3](images/task3-3.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#初学git感觉挺难的,学了一段时间后发现确实挺难的 | ||
##学会了git的基本操作如init clone branch checkout remote等等 | ||
##学习过程中参考了CSDN上资料,询问ai以及观看b站视频 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
![alt text](1-1.png) | ||
![alt text](1-2.png) | ||
![alt text](2-1.png) | ||
![alt text](2-2.png) | ||
![alt text](3-1.png) | ||
![alt text](3-2.png) |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# GIT application | ||
|
||
## 问题一 | ||
|
||
若你已经修改了部分文件、并且将其中的一部分加入了暂存区,应该如何回退这些修改,恢复到修改前最后一次提交的状态?给出至少两种不同的方式 | ||
|
||
- **方法一** | ||
|
||
使用 `git log` 获取上一次提交的哈希值 | ||
|
||
再使用 `git reset --hard 哈希值` 将当前分支指向上一次提交 | ||
|
||
![1730973551814](1730973551814.png) | ||
|
||
- **方法二** | ||
|
||
使用 `git reset HEAD` 撤销暂存区的改动 | ||
|
||
再使用 `git checkout -- .` 恢复工作区到上一次提交的状态 | ||
|
||
![1730973950652](1730973950652.png) | ||
|
||
- **方法三** | ||
|
||
使用 `git revert` 回退版本 | ||
|
||
## 问题二 | ||
|
||
若你已经提交了一个新版本,需要回退该版本,应该如何操作?分别给出不修改历史或修改历史的至少两种不同的方式 | ||
|
||
**不修改历史记录** | ||
|
||
- **方法一:** | ||
|
||
使用 `git revert 哈希值` ,创建一个新提交而不改变历史记录 | ||
|
||
![4e98bb70d8bfe46544f89e7a4a7167b](4e98bb70d8bfe46544f89e7a4a7167b.png) | ||
|
||
- **方法二:** | ||
|
||
使用 `git checkout` 切换到之前的提交,但是会导致头指针处于分离状态 | ||
|
||
![1730975404428](1730975404428.png) | ||
|
||
**修改历史记录** | ||
|
||
- **方法一:** | ||
|
||
使用 `git reset --hard 哈希值` 将HEAD指向对应的哈希值,但会舍弃对应哈希值以后的修改 | ||
|
||
![1730975905293](1730975905293.jpg) | ||
|
||
- **方法二:** | ||
|
||
使用`git rebase -i HEAD~n` , 打开并编辑n个提交,若要删除提交,把前面的 pick 改成 drop 即可 | ||
|
||
![1730976291580](1730976291580.png) | ||
|
||
![1730976267394](1730976267394.jpg) | ||
|
||
| ||
|
||
## 问题三 | ||
|
||
我们已经知道了合并分支可以使用 merge,但这不是唯一的方法,给出至少两种不同的合并分支的方式 | ||
|
||
- **方法一:** | ||
|
||
使用 `git cherry-pick 哈希值` 可将其他分支的提交合并到当前分支上,只需要其他分支提交的哈希值即可 | ||
|
||
![1730977416239](1730977416239.jpg) | ||
|
||
- **方法二:** | ||
|
||
使用 `git rebase 分支名` 将一个指定分支和并到当前分支上 | ||
|
||
![a](1730978038176.jpg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# Learning Git | ||
|
||
## Git 简介 | ||
|
||
git是一个版本控制的工具,可以很方便地对项目进行管理。 | ||
|
||
比如要对原项目增加新功能时,只需要新建一个分支,在分支的基础进行修改并提交即可。即使提交的有问题,也能随时回溯到之前的版本。分支的性质也极大的方便了多人同时对代码进行修改,每个人负责不同的部分,最后只需将每个人的分支合并,即可得到最后的所有修改。 | ||
|
||
## Git基本结构 | ||
|
||
### 分区 | ||
|
||
git主要分为三个区:工作区、暂存区、版本库 | ||
|
||
- 工作区:修改代码的地方 | ||
- 暂存区:工作区与提交的过渡,用于暂存工作区修改的代码,可随时提交 | ||
- 版本库:储存着当前版本和过去所有提交的记录,可随时回溯到之前的某一次提交 | ||
|
||
### 三者关系 | ||
|
||
1. **工作区 -> 暂存区** | ||
|
||
``` | ||
git add 文件名 | ||
``` | ||
|
||
或者一次性提交所有文件: | ||
|
||
``` | ||
git add . | ||
``` | ||
|
||
2. **暂存区 -> 版本库** | ||
|
||
``` | ||
git commit -m "本次提交的修改内容,要用纯英文!!!" | ||
``` | ||
|
||
3. **版本库 -> 远程仓库(如github)** | ||
|
||
``` | ||
git push 远程仓库名 分支名 | ||
``` | ||
|
||
|
||
|
||
## 常用命令 | ||
|
||
()内为可不加 | ||
|
||
| 作用 | 命令 | | ||
| ------------------------ | --------------------- | | ||
| 初始化仓库 | git init | | ||
| 查看当前仓库状态 | git status | | ||
| 查看历史提交日志及版本号 | git log | | ||
| 查看所有分支(切换分支) | git checkout (分支名) | | ||
| 将文件加入暂存区 | git add 文件名 | | ||
| 将暂存区文件提交到版本库 | git commit | | ||
| 克隆其他仓库 | git clone | | ||
| 回退到某一版本 | git reset | | ||
| 撤销某一版本提交 | git revert | | ||
|
||
|
||
|
||
## Git与Github | ||
|
||
github为远程仓库,可以储存项目的代码 | ||
|
||
### 连接远程仓库github | ||
|
||
- 添加远程仓库 | ||
|
||
``` | ||
git remote add 自己指定的仓库名 ssh密匙 | ||
``` | ||
|
||
- 在github上添加本地git仓库的ssh密匙: | ||
|
||
1. 生成密匙 | ||
|
||
``` | ||
ssh-keygen -t rsa -C "github注册的邮箱" | ||
``` | ||
2. 在 **.ssh/** 下找到 **id_rsa.pub** ,复制密匙,粘贴到 **github->setting->New SSH Key** 里面 | ||
### 将本地内容推到github | ||
- 推送你的新分支与数据到某个远端仓库命令: | ||
``` | ||
git push [alias] [branch] | ||
``` | ||
- 以上命令将你的 [branch] 分支推送成为 [alias] 远程仓库上的 [branch] 分支,实例如下。 | ||
``` | ||
$ touch runoob-test.txt # 添加文件 | ||
$ git add runoob-test.txt | ||
$ git commit -m "添加到远程" | ||
master 69e702d] 添加到远程 | ||
1 file changed, 0 insertions(+), 0 deletions(-) | ||
create mode 100644 runoob-test.txt | ||
|
||
$ git push origin master # 推送到 Github | ||
``` | ||
### 将github更新拉到仓库 | ||
1、从远程仓库下载新分支与数据: | ||
``` | ||
git fetch 远程仓库名(自己之前取的) | ||
``` | ||
该命令执行完后需要执行 git merge 远程分支到你所在的分支。 | ||
2、从远端仓库提取数据并尝试合并到当前分支: | ||
``` | ||
git merge 当前分支名 | ||
``` | ||
该命令就是在执行 **git fetch** 之后紧接着执行 **git merge** 远程分支到你所在的任意分支。 | ||