vault backup: 2026-11-07 16:33:44
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#### 3.1 工作原理简述
|
||||
|
||||
1. **触发器(Events)**:像 `push`、`pull_request`、`tag_push` 等事件会触发对应的工作流。
|
||||
2. **工作流(Workflow)文件**:默认存储在仓库的 `.gitea/workflows/` 目录下(或自定义)。类似 GitHub Actions,一般命名为 `main.yml` 或 `*.yml`。
|
||||
3. **Runner**:一旦事件触发,Gitea 会调用 Runner 进行执行。Runner 就是一个容器/服务器,里边通过 `act` 工具解析并执行 `.gitea/workflows/*.yml` 中的 steps。
|
||||
4. **steps / jobs**:在定义的 workflow 中,可以分多个 job,每个 job 再包含多个 step,依次执行 shell 命令或调用各种 actions(如 `actions/checkout@v4` 等)。
|
||||
|
||||
#### 3.2 存放[工作流](https://so.csdn.net/so/search?q=%E5%B7%A5%E4%BD%9C%E6%B5%81&spm=1001.2101.3001.7020)文件的位置
|
||||
|
||||
- **默认位置**:在 Gitea 仓库的根目录下新建 `.gitea/workflows/` 文件夹,然后在里面放置你的工作流文件,如 `main.yml`、`build.yml` 等。
|
||||
- **可自定义**:如果你在仓库的 `Settings` 里修改了默认的 workflow 路径,你就需要把 `.yml` 文件放在你指定的目录里。
|
||||
|
||||
例如,我们可以在仓库中新建:
|
||||
|
||||
```
|
||||
.gitea
|
||||
└─ workflows
|
||||
└─ main.yml
|
||||
```
|
||||
|
||||
然后把下面这段示例写到 `main.yml` 里即可。
|
||||
![[cc515c8d4a015321486e8e18ca98ebb9_2ac444af0f4840cda3a64e98950ac8b4.png]]
|
||||
@@ -0,0 +1,369 @@
|
||||
|
||||
# Lazygit 按键绑定
|
||||
|
||||
_Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
|
||||
|
||||
## 全局键绑定
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-r> `` | 切换到最近的仓库 | |
|
||||
| `` <pgup> (fn+up/shift+k) `` | 向上滚动主面板 | |
|
||||
| `` <pgdown> (fn+down/shift+j) `` | 向下滚动主面板 | |
|
||||
| `` @ `` | 打开命令日志菜单 | View options for the command log e.g. show/hide the command log and focus the command log. |
|
||||
| `` P `` | 推送 | Push the current branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. |
|
||||
| `` p `` | 拉取 | Pull changes from the remote for the current branch. If no upstream is configured, you will be prompted to configure an upstream branch. |
|
||||
| `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename. |
|
||||
| `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename. |
|
||||
| `` } `` | 扩大差异视图中显示的上下文范围 | Increase the amount of the context shown around changes in the diff view. |
|
||||
| `` { `` | 缩小差异视图中显示的上下文范围 | Decrease the amount of the context shown around changes in the diff view. |
|
||||
| `` : `` | 执行自定义命令 | Bring up a prompt where you can enter a shell command to execute. Not to be confused with pre-configured custom commands. |
|
||||
| `` <c-p> `` | 查看自定义补丁选项 | |
|
||||
| `` m `` | 查看 合并/变基 选项 | View options to abort/continue/skip the current merge/rebase. |
|
||||
| `` R `` | 刷新 | Refresh the git state (i.e. run `git status`, `git branch`, etc in background to update the contents of panels). This does not run `git fetch`. |
|
||||
| `` + `` | 下一屏模式(正常/半屏/全屏) | |
|
||||
| `` _ `` | 上一屏模式 | |
|
||||
| `` ? `` | 打开菜单 | |
|
||||
| `` <c-s> `` | 查看按路径过滤选项 | View options for filtering the commit log, so that only commits matching the filter are shown. |
|
||||
| `` W `` | 打开 diff 菜单 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
|
||||
| `` <c-e> `` | 打开 diff 菜单 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
|
||||
| `` q `` | 退出 | |
|
||||
| `` <esc> `` | 取消 | |
|
||||
| `` <c-w> `` | 切换是否在差异视图中显示空白字符差异 | Toggle whether or not whitespace changes are shown in the diff view. |
|
||||
| `` z `` | (通过 reflog)撤销「实验功能」 | The reflog will be used to determine what git command to run to undo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
|
||||
| `` <c-z> `` | (通过 reflog)重做「实验功能」 | The reflog will be used to determine what git command to run to redo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
|
||||
|
||||
## 列表面板导航
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` , `` | 上一页 | |
|
||||
| `` . `` | 下一页 | |
|
||||
| `` < `` | 滚动到顶部 | |
|
||||
| `` > `` | 滚动到底部 | |
|
||||
| `` v `` | 切换拖动选择 | |
|
||||
| `` <s-down> `` | Range select down | |
|
||||
| `` <s-up> `` | Range select up | |
|
||||
| `` / `` | 开始搜索 | |
|
||||
| `` H `` | 向左滚动 | |
|
||||
| `` L `` | 向右滚动 | |
|
||||
| `` ] `` | 下一个标签 | |
|
||||
| `` [ `` | 上一个标签 | |
|
||||
|
||||
## Reflog 页面
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-o> `` | 将提交的 hash 复制到剪贴板 | |
|
||||
| `` <space> `` | 检出 | Checkout the selected commit as a detached HEAD. |
|
||||
| `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
|
||||
| `` o `` | 在浏览器中打开提交 | |
|
||||
| `` n `` | 从提交创建新分支 | |
|
||||
| `` g `` | 查看重置选项 | View reset options (soft/mixed/hard) for resetting onto selected item. |
|
||||
| `` C `` | 复制提交(拣选) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
|
||||
| `` <c-r> `` | 重置已拣选(复制)的提交 | |
|
||||
| `` <c-t> `` | Open external diff tool (git difftool) | |
|
||||
| `` <enter> `` | 查看提交 | |
|
||||
| `` w `` | View worktree options | |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
## Worktrees
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` n `` | New worktree | |
|
||||
| `` <space> `` | Switch | Switch to the selected worktree. |
|
||||
| `` o `` | Open in editor | |
|
||||
| `` d `` | Remove | Remove the selected worktree. This will both delete the worktree's directory, as well as metadata about the worktree in the .git directory. |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
## 分支页面
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-o> `` | 将分支名称复制到剪贴板 | |
|
||||
| `` i `` | 显示 git-flow 选项 | |
|
||||
| `` <space> `` | 检出 | Checkout selected item. |
|
||||
| `` n `` | 新分支 | |
|
||||
| `` o `` | 创建抓取请求 | |
|
||||
| `` O `` | 创建抓取请求选项 | |
|
||||
| `` <c-y> `` | 将抓取请求 URL 复制到剪贴板 | |
|
||||
| `` c `` | 按名称检出 | Checkout by name. In the input box you can enter '-' to switch to the last branch. |
|
||||
| `` F `` | 强制检出 | Force checkout selected branch. This will discard all local changes in your working directory before checking out the selected branch. |
|
||||
| `` d `` | Delete | View delete options for local/remote branch. |
|
||||
| `` r `` | 将已检出的分支变基到该分支 | Rebase the checked-out branch onto the selected branch. |
|
||||
| `` M `` | 合并到当前检出的分支 | View options for merging the selected item into the current branch (regular merge, squash merge) |
|
||||
| `` f `` | 从上游快进此分支 | Fast-forward selected branch from its upstream. |
|
||||
| `` T `` | 创建标签 | |
|
||||
| `` s `` | Sort order | |
|
||||
| `` g `` | 查看重置选项 | |
|
||||
| `` R `` | 重命名分支 | |
|
||||
| `` u `` | View upstream options | View options relating to the branch's upstream e.g. setting/unsetting the upstream and resetting to the upstream. |
|
||||
| `` <c-t> `` | Open external diff tool (git difftool) | |
|
||||
| `` <enter> `` | 查看提交 | |
|
||||
| `` w `` | View worktree options | |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
## 子提交
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-o> `` | 将提交的 hash 复制到剪贴板 | |
|
||||
| `` <space> `` | 检出 | Checkout the selected commit as a detached HEAD. |
|
||||
| `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
|
||||
| `` o `` | 在浏览器中打开提交 | |
|
||||
| `` n `` | 从提交创建新分支 | |
|
||||
| `` g `` | 查看重置选项 | View reset options (soft/mixed/hard) for resetting onto selected item. |
|
||||
| `` C `` | 复制提交(拣选) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
|
||||
| `` <c-r> `` | 重置已拣选(复制)的提交 | |
|
||||
| `` <c-t> `` | Open external diff tool (git difftool) | |
|
||||
| `` <enter> `` | 查看提交的文件 | |
|
||||
| `` w `` | View worktree options | |
|
||||
| `` / `` | 开始搜索 | |
|
||||
|
||||
## 子模块
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-o> `` | 将子模块名称复制到剪贴板 | |
|
||||
| `` <enter> `` | Enter | 输入子模块 |
|
||||
| `` d `` | Remove | Remove the selected submodule and its corresponding directory. |
|
||||
| `` u `` | Update | 更新子模块 |
|
||||
| `` n `` | 添加新的子模块 | |
|
||||
| `` e `` | 更新子模块 URL | |
|
||||
| `` i `` | Initialize | 初始化子模块 |
|
||||
| `` b `` | 查看批量子模块选项 | |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
## 提交
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-o> `` | 将提交的 hash 复制到剪贴板 | |
|
||||
| `` <c-r> `` | 重置已拣选(复制)的提交 | |
|
||||
| `` b `` | 查看二分查找选项 | |
|
||||
| `` s `` | 压缩 | Squash the selected commit into the commit below it. The selected commit's message will be appended to the commit below it. |
|
||||
| `` f `` | 修正(fixup) | Meld the selected commit into the commit below it. Similar to squash, but the selected commit's message will be discarded. |
|
||||
| `` r `` | 改写提交 | Reword the selected commit's message. |
|
||||
| `` R `` | 使用编辑器重命名提交 | |
|
||||
| `` d `` | 删除提交 | Drop the selected commit. This will remove the commit from the branch via a rebase. If the commit makes changes that later commits depend on, you may need to resolve merge conflicts. |
|
||||
| `` e `` | Edit (start interactive rebase) | 编辑提交 |
|
||||
| `` i `` | Start interactive rebase | Start an interactive rebase for the commits on your branch. This will include all commits from the HEAD commit down to the first merge commit or main branch commit.
|
||||
If you would instead like to start an interactive rebase from the selected commit, press `e`. |
|
||||
| `` p `` | Pick | 选择提交(变基过程中) |
|
||||
| `` F `` | 为此提交创建修正 | 创建修正提交 |
|
||||
| `` S `` | Apply fixup commits | 压缩在所选提交之上的所有“fixup!”提交(自动压缩) |
|
||||
| `` <c-j> `` | 下移提交 | |
|
||||
| `` <c-k> `` | 上移提交 | |
|
||||
| `` V `` | 粘贴提交(拣选) | |
|
||||
| `` B `` | Mark as base commit for rebase | Select a base commit for the next rebase. When you rebase onto a branch, only commits above the base commit will be brought across. This uses the `git rebase --onto` command. |
|
||||
| `` A `` | Amend | 用已暂存的更改来修补提交 |
|
||||
| `` a `` | Amend commit attribute | Set/Reset commit author or set co-author. |
|
||||
| `` t `` | Revert | Create a revert commit for the selected commit, which applies the selected commit's changes in reverse. |
|
||||
| `` T `` | 标签提交 | Create a new tag pointing at the selected commit. You'll be prompted to enter a tag name and optional description. |
|
||||
| `` <c-l> `` | 打开日志菜单 | View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph. |
|
||||
| `` <space> `` | 检出 | Checkout the selected commit as a detached HEAD. |
|
||||
| `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
|
||||
| `` o `` | 在浏览器中打开提交 | |
|
||||
| `` n `` | 从提交创建新分支 | |
|
||||
| `` g `` | 查看重置选项 | View reset options (soft/mixed/hard) for resetting onto selected item. |
|
||||
| `` C `` | 复制提交(拣选) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
|
||||
| `` <c-t> `` | Open external diff tool (git difftool) | |
|
||||
| `` <enter> `` | 查看提交的文件 | |
|
||||
| `` w `` | View worktree options | |
|
||||
| `` / `` | 开始搜索 | |
|
||||
|
||||
## 提交文件
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-o> `` | 将文件名复制到剪贴板 | |
|
||||
| `` c `` | 检出 | 检出文件 |
|
||||
| `` d `` | Remove | 放弃对此文件的提交更改 |
|
||||
| `` o `` | 打开文件 | Open file in default application. |
|
||||
| `` e `` | Edit | Open file in external editor. |
|
||||
| `` <c-t> `` | Open external diff tool (git difftool) | |
|
||||
| `` <space> `` | 补丁中包含的切换文件 | Toggle whether the file is included in the custom patch. See https://github.com/jesseduffield/lazygit#rebase-magic-custom-patches. |
|
||||
| `` a `` | Toggle all files | Add/remove all commit's files to custom patch. See https://github.com/jesseduffield/lazygit#rebase-magic-custom-patches. |
|
||||
| `` <enter> `` | 输入文件以将所选行添加到补丁中(或切换目录折叠) | If a file is selected, enter the file so that you can add/remove individual lines to the custom patch. If a directory is selected, toggle the directory. |
|
||||
| `` ` `` | 切换文件树视图 | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. |
|
||||
| `` / `` | 开始搜索 | |
|
||||
|
||||
## 提交讯息
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <enter> `` | 确认 | |
|
||||
| `` <esc> `` | 关闭 | |
|
||||
|
||||
## 文件
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-o> `` | 将文件名复制到剪贴板 | |
|
||||
| `` <space> `` | 切换暂存状态 | Toggle staged for selected file. |
|
||||
| `` <c-b> `` | Filter files by status | |
|
||||
| `` y `` | Copy to clipboard | |
|
||||
| `` c `` | 提交更改 | Commit staged changes. |
|
||||
| `` w `` | 提交更改而无需预先提交钩子 | |
|
||||
| `` A `` | 修补最后一次提交 | |
|
||||
| `` C `` | 提交更改(使用编辑器编辑提交信息) | |
|
||||
| `` <c-f> `` | Find base commit for fixup | Find the commit that your current changes are building upon, for the sake of amending/fixing up the commit. This spares you from having to look through your branch's commits one-by-one to see which commit should be amended/fixed up. See docs: <https://github.com/jesseduffield/lazygit/tree/master/docs/Fixup_Commits.md> |
|
||||
| `` e `` | Edit | Open file in external editor. |
|
||||
| `` o `` | 打开文件 | Open file in default application. |
|
||||
| `` i `` | 忽略文件 | |
|
||||
| `` r `` | 刷新文件 | |
|
||||
| `` s `` | Stash | Stash all changes. For other variations of stashing, use the view stash options keybinding. |
|
||||
| `` S `` | 查看贮藏选项 | View stash options (e.g. stash all, stash staged, stash unstaged). |
|
||||
| `` a `` | 切换所有文件的暂存状态 | Toggle staged/unstaged for all files in working tree. |
|
||||
| `` <enter> `` | 暂存单个 块/行 用于文件, 或 折叠/展开 目录 | If the selected item is a file, focus the staging view so you can stage individual hunks/lines. If the selected item is a directory, collapse/expand it. |
|
||||
| `` d `` | 查看'放弃更改'选项 | View options for discarding changes to the selected file. |
|
||||
| `` g `` | 查看上游重置选项 | |
|
||||
| `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). |
|
||||
| `` ` `` | 切换文件树视图 | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. |
|
||||
| `` <c-t> `` | Open external diff tool (git difftool) | |
|
||||
| `` M `` | 打开外部合并工具 (git mergetool) | Run `git mergetool`. |
|
||||
| `` f `` | 抓取 | Fetch changes from remote. |
|
||||
| `` / `` | 开始搜索 | |
|
||||
|
||||
## 构建补丁中
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <left> `` | 选择上一个区块 | |
|
||||
| `` <right> `` | 选择下一个区块 | |
|
||||
| `` v `` | 切换拖动选择 | |
|
||||
| `` a `` | 切换选择区块 | Toggle hunk selection mode. |
|
||||
| `` <c-o> `` | 将选中文本复制到剪贴板 | |
|
||||
| `` o `` | 打开文件 | Open file in default application. |
|
||||
| `` e `` | 编辑文件 | Open file in external editor. |
|
||||
| `` <space> `` | 添加/移除 行到补丁 | |
|
||||
| `` <esc> `` | 退出逐行模式 | |
|
||||
| `` / `` | 开始搜索 | |
|
||||
|
||||
## 标签页面
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <space> `` | 检出 | Checkout the selected tag tag as a detached HEAD. |
|
||||
| `` n `` | 创建标签 | Create new tag from current commit. You'll be prompted to enter a tag name and optional description. |
|
||||
| `` d `` | Delete | View delete options for local/remote tag. |
|
||||
| `` P `` | 推送标签 | Push the selected tag to a remote. You'll be prompted to select a remote. |
|
||||
| `` g `` | Reset | View reset options (soft/mixed/hard) for resetting onto selected item. |
|
||||
| `` <c-t> `` | Open external diff tool (git difftool) | |
|
||||
| `` <enter> `` | 查看提交 | |
|
||||
| `` w `` | View worktree options | |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
## 正在合并
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <space> `` | 选中区块 | |
|
||||
| `` b `` | 选中所有区块 | |
|
||||
| `` <up> `` | 选择顶部块 | |
|
||||
| `` <down> `` | 选择底部块 | |
|
||||
| `` <left> `` | 选择上一个冲突 | |
|
||||
| `` <right> `` | 选择下一个冲突 | |
|
||||
| `` z `` | 撤销 | Undo last merge conflict resolution. |
|
||||
| `` e `` | 编辑文件 | Open file in external editor. |
|
||||
| `` o `` | 打开文件 | Open file in default application. |
|
||||
| `` M `` | 打开外部合并工具 (git mergetool) | Run `git mergetool`. |
|
||||
| `` <esc> `` | 返回文件面板 | |
|
||||
|
||||
## 正在暂存
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <left> `` | 选择上一个区块 | |
|
||||
| `` <right> `` | 选择下一个区块 | |
|
||||
| `` v `` | 切换拖动选择 | |
|
||||
| `` a `` | 切换选择区块 | Toggle hunk selection mode. |
|
||||
| `` <c-o> `` | 将选中文本复制到剪贴板 | |
|
||||
| `` <space> `` | 切换暂存状态 | 切换行暂存状态 |
|
||||
| `` d `` | 取消变更 (git reset) | When unstaged change is selected, discard the change using `git reset`. When staged change is selected, unstage the change. |
|
||||
| `` o `` | 打开文件 | Open file in default application. |
|
||||
| `` e `` | 编辑文件 | Open file in external editor. |
|
||||
| `` <esc> `` | 返回文件面板 | |
|
||||
| `` <tab> `` | 切换到其他面板 | Switch to other view (staged/unstaged changes). |
|
||||
| `` E `` | Edit hunk | Edit selected hunk in external editor. |
|
||||
| `` c `` | 提交更改 | Commit staged changes. |
|
||||
| `` w `` | 提交更改而无需预先提交钩子 | |
|
||||
| `` C `` | 提交更改(使用编辑器编辑提交信息) | |
|
||||
| `` <c-f> `` | Find base commit for fixup | Find the commit that your current changes are building upon, for the sake of amending/fixing up the commit. This spares you from having to look through your branch's commits one-by-one to see which commit should be amended/fixed up. See docs: <https://github.com/jesseduffield/lazygit/tree/master/docs/Fixup_Commits.md> |
|
||||
| `` / `` | 开始搜索 | |
|
||||
|
||||
## 正常
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` mouse wheel down (fn+up) `` | 向下滚动 | |
|
||||
| `` mouse wheel up (fn+down) `` | 向上滚动 | |
|
||||
|
||||
## 状态
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` o `` | 打开配置文件 | Open file in default application. |
|
||||
| `` e `` | 编辑配置文件 | Open file in external editor. |
|
||||
| `` u `` | 检查更新 | |
|
||||
| `` <enter> `` | 切换到最近的仓库 | |
|
||||
| `` a `` | 显示所有分支的日志 | |
|
||||
|
||||
## 确认面板
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <enter> `` | 确认 | |
|
||||
| `` <esc> `` | 关闭 | |
|
||||
|
||||
## 菜单
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <enter> `` | 执行 | |
|
||||
| `` <esc> `` | 关闭 | |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
## 贮藏
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <space> `` | 应用 | Apply the stash entry to your working directory. |
|
||||
| `` g `` | 应用并删除 | Apply the stash entry to your working directory and remove the stash entry. |
|
||||
| `` d `` | 删除 | Remove the stash entry from the stash list. |
|
||||
| `` n `` | 新分支 | Create a new branch from the selected stash entry. This works by git checking out the commit that the stash entry was created from, creating a new branch from that commit, then applying the stash entry to the new branch as an additional commit. |
|
||||
| `` r `` | Rename stash | |
|
||||
| `` <enter> `` | 查看提交的文件 | |
|
||||
| `` w `` | View worktree options | |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
## 远程分支
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <c-o> `` | 将分支名称复制到剪贴板 | |
|
||||
| `` <space> `` | 检出 | Checkout a new local branch based on the selected remote branch, or the remote branch as a detached head. |
|
||||
| `` n `` | 新分支 | |
|
||||
| `` M `` | 合并到当前检出的分支 | View options for merging the selected item into the current branch (regular merge, squash merge) |
|
||||
| `` r `` | 将已检出的分支变基到该分支 | Rebase the checked-out branch onto the selected branch. |
|
||||
| `` d `` | Delete | Delete the remote branch from the remote. |
|
||||
| `` u `` | Set as upstream | 设置为检出分支的上游 |
|
||||
| `` s `` | Sort order | |
|
||||
| `` g `` | 查看重置选项 | View reset options (soft/mixed/hard) for resetting onto selected item. |
|
||||
| `` <c-t> `` | Open external diff tool (git difftool) | |
|
||||
| `` <enter> `` | 查看提交 | |
|
||||
| `` w `` | View worktree options | |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
## 远程页面
|
||||
|
||||
| Key | Action | Info |
|
||||
|-----|--------|-------------|
|
||||
| `` <enter> `` | View branches | |
|
||||
| `` n `` | 添加新的远程仓库 | |
|
||||
| `` d `` | Remove | Remove the selected remote. Any local branches tracking a remote branch from the remote will be unaffected. |
|
||||
| `` e `` | Edit | 编辑远程仓库 |
|
||||
| `` f `` | 抓取 | 抓取远程仓库 |
|
||||
| `` / `` | Filter the current view by text | |
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
```
|
||||
git config --global credential.helper manager
|
||||
```
|
||||
|
||||
这个命令,简单来说,就是给 Git 配置了一个“万能钥匙管理器”。
|
||||
|
||||
它的核心作用就是**告诉 Git,让它在需要仓库密码或令牌等验证信息时,统一交由 Git Credential Manager (GCM) 这个专用的凭证管理工具来处理**
|
||||
|
||||
|
||||
|
||||
验证
|
||||
git config --global credential.helper
|
||||
@@ -0,0 +1,78 @@
|
||||
要查看 Git 仓库中**指定文件的所有修改记录**(包括谁、何时、改了什么),最直接的方法就是使用 `git log` 配合文件名。
|
||||
|
||||
### 📜 基本命令:显示所有影响该文件的提交
|
||||
|
||||
```bash
|
||||
git log -- <文件路径>
|
||||
```
|
||||
|
||||
示例:
|
||||
```bash
|
||||
git log -- src/main.py
|
||||
```
|
||||
|
||||
这样会按时间倒序列出所有修改过 `src/main.py` 的提交。
|
||||
|
||||
### 🔍 查看每次修改的具体内容(diff)
|
||||
|
||||
加上 `-p` 或 `--patch` 就能看到每次提交中该文件具体的增删行:
|
||||
|
||||
```bash
|
||||
git log -p -- src/main.py
|
||||
```
|
||||
|
||||
### 🚶 跟踪文件重命名/移动
|
||||
|
||||
如果文件曾被重命名或移动过,默认 `git log` 不会自动跟踪。加上 `--follow` 即可:
|
||||
|
||||
```bash
|
||||
git log --follow -p -- src/main.py
|
||||
```
|
||||
|
||||
> 注意:`--follow` 在某些 Git 版本中不能与 `--reverse` 等参数同时使用,但基本场景够用。
|
||||
|
||||
### 📅 更紧凑的显示(一行摘要 + 统计)
|
||||
|
||||
```bash
|
||||
git log --oneline --stat -- src/main.py
|
||||
```
|
||||
|
||||
- `--oneline`:每个提交一行
|
||||
- `--stat`:显示文件修改的统计(增加/删除行数)
|
||||
|
||||
### 🎯 只查看某个时间范围或作者
|
||||
|
||||
```bash
|
||||
# 最近 5 次修改
|
||||
git log -5 -- src/main.py
|
||||
|
||||
# 某个作者
|
||||
git log --author="张三" -- src/main.py
|
||||
|
||||
# 某个日期之后
|
||||
git log --since="2024-01-01" -- src/main.py
|
||||
```
|
||||
|
||||
### 💡 补充:逐行查看文件每行的最后修改
|
||||
|
||||
如果你想知道文件每一行最后一次是谁改的,用 `git blame`:
|
||||
|
||||
```bash
|
||||
git blame <文件路径>
|
||||
```
|
||||
|
||||
这会输出每行的内容、提交哈希、作者、时间。如果你想忽略空白或移动过的行,可以用 `git blame -w -C`。
|
||||
|
||||
---
|
||||
|
||||
### 总结
|
||||
|
||||
| 需求 | 命令 |
|
||||
|------|------|
|
||||
| 只看提交列表 | `git log -- <file>` |
|
||||
| 看每次改了什么 | `git log -p -- <file>` |
|
||||
| 跟踪重命名 | `git log --follow -p -- <file>` |
|
||||
| 统计改了多少行 | `git log --stat -- <file>` |
|
||||
| 查看每行最后修改人 | `git blame <file>` |
|
||||
|
||||
这些命令足够覆盖日常查看文件历史的需求。
|
||||
@@ -0,0 +1,59 @@
|
||||
**能,而且可以非常灵活地在多个分支上重复使用。**
|
||||
|
||||
Git 的 Stash(贮藏)功能可以把它想象成一个“**代码剪贴板**”,里面的内容和“创建”它的那个分支早已没有了绑定关系,可以随意粘贴到任何其他分支上。
|
||||
|
||||
### 🎯 核心:使用 `git stash apply`
|
||||
|
||||
要在别的分支提取,关键就是使用 `git stash apply` 命令,而不是 `pop`。
|
||||
|
||||
**`apply` vs `pop` 的区别**:
|
||||
|
||||
| 命令 | 恢复后 | 适用场景 |
|
||||
| :--- | :--- | :--- |
|
||||
| `git stash apply` | Stash 内容**保留**在堆栈中 | 需要将同一份修改应用到多个分支,对代码改动进行交叉测试 |
|
||||
| `git stash pop` | 恢复后,对应的 Stash 会**被删除** | 适合只想把代码“移动”到另一个分支,不需要再保留这份修改的场景 |
|
||||
|
||||
### 🧭 操作指南:一份 Stash 在多分支间复用
|
||||
|
||||
1. **保存当前工作**:
|
||||
```bash
|
||||
# 建议添加描述,方便日后识别
|
||||
git stash push -m "进行中但没有完成的功能X"
|
||||
```
|
||||
|
||||
2. **应用到目标分支**:
|
||||
```bash
|
||||
# 切换到你要应用修改的分支
|
||||
git checkout 目标分支名
|
||||
|
||||
# 将 Stash 中的修改应用过来
|
||||
git stash apply
|
||||
|
||||
# 如果本地有多个 Stash,用以下命令查看列表,
|
||||
# 再用 git stash apply stash@{n} 应用特定的一个
|
||||
git stash list
|
||||
```
|
||||
**执行后**:代码改动会出现在当前分支的工作区,`git stash list` 里原来的记录还在,意味着你可以去下一个分支继续执行 `git stash apply`。
|
||||
|
||||
3. **(可选)应用完成后清理**:当所有需要的分支都应用完毕,不再需要这份 Stash 时,可以手动清理掉:
|
||||
```bash
|
||||
git stash drop stash@{0}
|
||||
```
|
||||
|
||||
### ⚠️ 可能遇到的问题及解决方案
|
||||
|
||||
**问题:应用时产生合并冲突**
|
||||
当目标分支的代码与你存储的内容差异较大,导致 Git 不知道如何自动合并时,就会出现冲突。
|
||||
|
||||
**解决方案**:冲突的产生是正常现象,手动处理即可。
|
||||
1. **找到冲突**:Git 会告诉你哪些文件冲突并暂停应用。
|
||||
2. **手动解决**:打开冲突文件,编辑代码,保留你需要的部分(通常删除 `<<<<<<<`,`=======`,`>>>>>>>` 这些标记)。
|
||||
3. **告知 Git**:解决后保存文件,并执行 `git add <冲突文件名>`。
|
||||
4. **完成应用**:无需额外提交,`add` 命令后,Stash 的应用即告完成。
|
||||
|
||||
### 🚀 其他常用管理命令
|
||||
|
||||
* **查看所有 Stash**:`git stash list`。
|
||||
* **从 Stash 直接创建新分支**:`git stash branch <新分支名> stash@{0}`。这会将你的 Stash 恢复到一个新的独立分支,在复杂改动时特别好用。
|
||||
* **存储未跟踪的文件**:`git stash -u`。
|
||||
* **清理所有 Stash**:`git stash clear`。
|
||||
@@ -0,0 +1,158 @@
|
||||
在 Git 中同时处理多个分支的需求很常见,以下是几种高效的方法和技巧:
|
||||
|
||||
## 1. 使用 Git Worktree(推荐)
|
||||
|
||||
Git Worktree 允许你在同一个仓库中同时检出多个分支到不同的目录。
|
||||
|
||||
```bash
|
||||
# 创建新的工作树(目录)
|
||||
git worktree add ../feature-branch feature/xxx
|
||||
git worktree add ../hotfix-branch hotfix/yyy
|
||||
|
||||
# 查看所有工作树
|
||||
git worktree list
|
||||
|
||||
# 删除工作树
|
||||
git worktree remove ../feature-branch
|
||||
```
|
||||
|
||||
**优点**:
|
||||
- 隔离的工作环境
|
||||
- 避免频繁切换分支
|
||||
- 可以同时编译不同分支的代码
|
||||
|
||||
## 2. 多目录克隆
|
||||
|
||||
```bash
|
||||
# 克隆到不同目录
|
||||
git clone /path/to/repo repo-main
|
||||
git clone /path/to/repo repo-feature
|
||||
git clone /path/to/repo repo-dev
|
||||
|
||||
# 在每个目录中检出不同分支
|
||||
cd repo-main && git checkout main
|
||||
cd repo-feature && git checkout feature/xxx
|
||||
cd repo-dev && git checkout develop
|
||||
```
|
||||
|
||||
## 3. 快速分支切换技巧
|
||||
|
||||
### 使用分支别名
|
||||
```bash
|
||||
# 设置分支别名(在.git/config中添加)
|
||||
[alias]
|
||||
co-main = checkout main
|
||||
co-feature = checkout feature/xxx
|
||||
co-dev = checkout develop
|
||||
```
|
||||
|
||||
### 智能补全
|
||||
```bash
|
||||
# 使用Tab补全分支名
|
||||
git checkout feat<Tab> # 自动补全为 feature/xxx
|
||||
|
||||
# 只匹配远程分支
|
||||
git checkout origin/<Tab>
|
||||
```
|
||||
|
||||
## 4. 批量分支操作
|
||||
|
||||
### 查看所有分支(包括远程)
|
||||
```bash
|
||||
# 查看本地和远程分支
|
||||
git branch -a
|
||||
|
||||
# 查看已合并的分支
|
||||
git branch --merged
|
||||
|
||||
# 查看未合并的分支
|
||||
git branch --no-merged
|
||||
```
|
||||
|
||||
### 批量删除分支
|
||||
```bash
|
||||
# 删除已合并的分支(谨慎使用)
|
||||
git branch --merged | grep -v "\*" | xargs git branch -d
|
||||
|
||||
# 删除匹配特定模式的分支
|
||||
git branch | grep "feature/" | xargs git branch -D
|
||||
```
|
||||
|
||||
## 5. 暂存当前工作
|
||||
|
||||
当需要临时切换分支时,使用 stash:
|
||||
|
||||
```bash
|
||||
# 保存当前修改
|
||||
git stash push -m "临时保存"
|
||||
|
||||
# 切换到其他分支工作
|
||||
git checkout other-branch
|
||||
|
||||
# 返回原分支并恢复
|
||||
git checkout original-branch
|
||||
git stash pop
|
||||
```
|
||||
|
||||
## 6. 并行开发工作流
|
||||
|
||||
### 场景:同时开发多个功能
|
||||
```bash
|
||||
# 工作树1:主要功能开发
|
||||
git worktree add ../feature-a feature/a
|
||||
cd ../feature-a
|
||||
|
||||
# 工作树2:修复bug
|
||||
git worktree add ../hotfix-b hotfix/b
|
||||
cd ../hotfix-b
|
||||
|
||||
# 工作树3:代码审查
|
||||
git worktree add ../review-c review/c
|
||||
cd ../review-c
|
||||
```
|
||||
|
||||
### 自动化脚本示例
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# setup-workspaces.sh
|
||||
|
||||
REPO_DIR="/path/to/repo"
|
||||
BRANCHES=("main" "develop" "feature/x" "feature/y")
|
||||
|
||||
for branch in "${BRANCHES[@]}"; do
|
||||
dir_name=$(echo $branch | sed 's/\//-/g')
|
||||
git worktree add "../$dir_name" "$branch"
|
||||
done
|
||||
```
|
||||
|
||||
## 7. 实用配置建议
|
||||
|
||||
### Git 配置优化
|
||||
```bash
|
||||
# 显示上游分支信息
|
||||
git config --global branch.autoSetupMerge always
|
||||
|
||||
# 更详细的分支状态
|
||||
git config --global format.pretty fuller
|
||||
|
||||
# 推送时自动设置上游分支
|
||||
git config --global push.autoSetupRemote true
|
||||
```
|
||||
|
||||
### Shell 别名
|
||||
```bash
|
||||
# 添加到 ~/.bashrc 或 ~/.zshrc
|
||||
alias gws='git worktree list'
|
||||
alias gwa='git worktree add'
|
||||
alias gwr='git worktree remove'
|
||||
alias gb='git branch --sort=-committerdate' # 按时间排序分支
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. **主分支保护**:使用 worktree 避免在主要开发分支上直接修改
|
||||
2. **定期清理**:删除不再需要的 worktree 和已合并的分支
|
||||
3. **命名规范**:工作树目录名与分支名对应,便于识别
|
||||
4. **资源管理**:注意多个工作树可能占用较多磁盘空间
|
||||
|
||||
这些技巧可以显著提高在多分支环境下的开发效率,特别是 Git Worktree 功能,它是处理并行开发任务的最佳选择。
|
||||
@@ -0,0 +1,20 @@
|
||||
- 合并默认选项
|
||||
- 回车键
|
||||
- credential 账号密码记住
|
||||
|
||||
```
|
||||
# 1. 保持原有换行符,不做 CRLF/LF 自动转换
|
||||
git config --global core.autocrlf false
|
||||
|
||||
# 2. pull 时默认使用 rebase(避免产生多余的 merge commit)
|
||||
git config --global pull.rebase true
|
||||
|
||||
# 3. 使用 credential 明文记录账号密码(保存在 ~/.git-credentials)
|
||||
git config --global credential.helper store
|
||||
|
||||
git config --global init.defaultBranch main
|
||||
|
||||
# 4. 默认身份
|
||||
git config --global user.name "cheney"
|
||||
git config --global user.email "hq@honor3.com"
|
||||
```
|
||||
@@ -0,0 +1,47 @@
|
||||
### 1. 撤销提交,但**保留所有修改**(最常用)
|
||||
执行后,最近的提交会被撤销,但你的代码改动会**保留在工作区**,方便你修改后重新提交。
|
||||
```bash
|
||||
git reset --soft HEAD~1
|
||||
```
|
||||
|
||||
### 2. 撤销提交,**取消暂存**,但保留修改
|
||||
执行后,提交被撤销,代码改动保留,但会从暂存区(`git add` 的状态)退回到未暂存状态(即需要重新 `git add`)。
|
||||
```bash
|
||||
git reset HEAD~1
|
||||
```
|
||||
(注:`git reset --mixed HEAD~1` 是等价的,`--mixed` 为默认参数)
|
||||
|
||||
---
|
||||
|
||||
### 3. 彻底删除最后一次提交及所有改动(**危险操作**)
|
||||
执行后,提交和所有代码改动都会**永久消失**(除非找回),请务必确认不需要这些改动了再执行。
|
||||
```bash
|
||||
git reset --hard HEAD~1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 4. 如果已经推送到远程仓库(**安全方案**)
|
||||
如果代码已经 `git push` 了,**不要用 `reset`**(强行推送会覆盖同事代码)。请使用 **`git revert`**,它会生成一个**新的提交**来反向撤销上次的内容,既安全又保留历史记录。
|
||||
```bash
|
||||
git revert HEAD
|
||||
# 随后会自动弹出编辑器让你填写提交信息,保存即可
|
||||
# 最后执行 git push 推送到远程
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 补充救急命令
|
||||
如果你不小心执行错了(比如用了 `--hard` 删多了),**只要没执行 `git gc`**,可以在 **24小时内** 用以下命令找回:
|
||||
```bash
|
||||
git reflog
|
||||
# 找到你想恢复的提交记录哈希值(如 a1b2c3d)
|
||||
git reset --hard a1b2c3d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**总结建议**:
|
||||
- 本地未推送 + 想保留修改 → 用 **方案 1**(`--soft`)
|
||||
- 已推送到远程 → 用 **方案 4**(`revert`)
|
||||
- 确定想彻底丢弃 → 用 **方案 3**(`--hard`),但请三思
|
||||
@@ -0,0 +1,63 @@
|
||||
## 1 基本概念
|
||||
|
||||
类似于 GitHub Actions,Gitea Actions 同样包含了工作流(Workflow)、事件(Event)、任务(Job)、步骤(Step)、运行器(Runner)等几项重要的基本概念。
|
||||
### 1.1 工作流
|
||||
|
||||
**工作流**是一个可配置的自动化过程。我们将本地写好的 Markdown 文件推送(`push`)到远程云服务器的 Gitea 仓库,触发后续 Markdown 向 HTML 页面的自动渲染及博客站点的自动发布更新,这个过程就是一个典型的工作流。
|
||||
|
||||
工作流由定义在仓库指定目录下的 YAML 脚本描述,对于 GitHub Actions 而言,这个目录是 `.github/workflows`,对于 Gitea Actions 而言,这个目录是 `.gitea/workflows`。
|
||||
|
||||
### 1.2 事件
|
||||
|
||||
**事件**是触发工作流开始运行的源头,仍以 Hexo 博客的 CI/CD 工作流为例,我们将 Markdown 文件 `push` 到远程云服务器 Gitea 仓库的动作就是一个事件。
|
||||
|
||||
### 1.3 任务和步骤
|
||||
|
||||
**任务**是工作流中一组**步骤**的集合,一个工作流可以包含多个任务,一个任务可以包含多个步骤,每个步骤都包含了若干条具体的操作命令。步骤按顺序执行,并且相互依赖。
|
||||
|
||||
我们可以配置工作流中任务间的依赖关系(默认无依赖关系,并行运行),当一个任务依赖于另一个任务时,它将等待所依赖任务完成后才能开始运行。
|
||||
|
||||
### 1.4 运行器
|
||||
|
||||
**运行器**是执行工作流任务的软件程序,工作流中的每个任务都需要指定运行器,不同的任务可以指定不同的运行器。
|
||||
|
||||
一个典型的 Gitea Actions 工作流如下图所示:
|
||||
|
||||

|
||||
|
||||
典型的 Gitea Actions 工作流
|
||||
|
||||
|
||||
## 2 环境配置
|
||||
### 2.1.1 全局配置
|
||||
Gitea 配置文件 `/etc/gitea/app.ini`,确保配置文件 `actions` 配置项并开启 Gitea Actions 功能:
|
||||
|
||||
```ini
|
||||
[actions]
|
||||
ENABLED = true
|
||||
```
|
||||
|
||||
|
||||
### 2.1.2 为指定仓库开启 Actions 功能
|
||||
|
||||
即使 Gitea Actions 已经在配置文件中开启,对于某个指定的仓库而言其 Actions 功能仍是默认关闭的,需要针对仓库进行单独配置:
|
||||
|
||||

|
||||
|
||||
为指定仓库开启 Actions
|
||||
|
||||
|
||||
### 2.2 部署 act runner
|
||||
|
||||
Gitea 使用 [act runner](https://link.zhihu.com/?target=https%3A//gitea.com/gitea/act_runner) 来执行具体的工作流任务。使用 docker 安装 act runner 的过程如下:
|
||||
- Step 1
|
||||
```bash
|
||||
docker run -e GITEA_INSTANCE_URL=https://your_gitea.com -e GITEA_RUNNER_REGISTRATION_TOKEN=<your_token> -v /var/run/docker.sock:/var/run/docker.sock --name cicd gitea/act_runner:nightly
|
||||
```
|
||||
|
||||
```bash
|
||||
GITEA_INSTANCE_URL 是 gitea 地址
|
||||
GITEA_RUNNER_REGISTRATION_TOKEN 是创建 runner 时自动生成的 token
|
||||
```
|
||||
|
||||
![[Pasted image 20240820093153.png]]gitee 在用户-设置下创建的 action 和在项目的设置下创建的 action 什么区别?
|
||||
Reference in New Issue
Block a user