mirror of
https://github.com/Dichgrem/Blog.git
synced 2025-12-16 05:22:00 -05:00
update:git
This commit is contained in:
38
.github/workflows/mirror-to-codeberg.yml
vendored
38
.github/workflows/mirror-to-codeberg.yml
vendored
@@ -1,38 +0,0 @@
|
||||
name: Mirror to Codeberg
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
mirror:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Push to Codeberg
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_CODEBERG }}
|
||||
REPO_URL_CODEBERG: ${{ secrets.REPO_URL_CODEBERG }}
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
cat >> ~/.ssh/config <<EOF
|
||||
Host codeberg.org
|
||||
IdentityFile ~/.ssh/id_ed25519
|
||||
StrictHostKeyChecking no
|
||||
EOF
|
||||
|
||||
git config --global user.name "GitHub Actions"
|
||||
git config --global user.email "github-actions@github.com"
|
||||
|
||||
git remote add codeberg "$REPO_URL_CODEBERG"
|
||||
git push --tags --force --prune codeberg "refs/remotes/origin/*:refs/heads/*"
|
||||
@@ -201,6 +201,50 @@ git push origin main
|
||||
```
|
||||
git pull
|
||||
```
|
||||
|
||||
> Verified
|
||||
|
||||
在 GitHub 的 commit 历史中看到的 “Verified” 标记,表示该提交是经过 签名验证(signed commit) 的,也就是 GitHub 能确认这个 commit 的确是由声明的提交者(你)签名并发布的。可以通过GPG或者SSH配置:
|
||||
|
||||
- GPG方式
|
||||
|
||||
```
|
||||
sudo pacman -S gnupg //安装 GPG
|
||||
gpg --full-generate-key //生成 GPG 密钥
|
||||
gpg --list-secret-keys --keyid-format=long //查看你生成的密钥 ID
|
||||
git config --global user.signingkey ABCDEF1234567890 //让 Git 使用该密钥签名
|
||||
git config --global commit.gpgsign true //启用自动签名所有提交
|
||||
gpg --armor --export ABCDEF1234567890 //导出公钥并添加到 GitHub
|
||||
```
|
||||
然后前往``GitHub → Settings → SSH and GPG keys → New GPG key``粘贴并保存。
|
||||
|
||||
- SSH方式
|
||||
|
||||
可以用你平时登录 GitHub 的同一个 SSH 密钥:
|
||||
```
|
||||
git config --global gpg.format ssh //让 Git 使用 SSH 格式签名
|
||||
git config --global user.signingkey ~/.ssh/Github.pub //指定使用的 SSH 公钥
|
||||
git config --global commit.gpgsign true //表示自动签名所有提交
|
||||
```
|
||||
然后前往``Settings → SSH and GPG keys → New SSH key → Signing key``粘贴并保存。
|
||||
|
||||
- 本地查看
|
||||
|
||||
首先创建这个文件:
|
||||
```
|
||||
mkdir -p ~/.ssh
|
||||
nano ~/.ssh/allowed_signers
|
||||
```
|
||||
写入你的 ``test@mail.com ssh-ed25519 AAAABBBBBBBBBBBBBBBBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx``并保存。
|
||||
随后配置Git信任该文件:
|
||||
```
|
||||
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
|
||||
```
|
||||
随后使用``git log --show-signature``即可查看本地log中的
|
||||
```
|
||||
Good "git" signature for test@mail.com with ED25519 key SHA256:ssh-ed25519 AAAABBBBBBBBBBBBBBBBBBBBB
|
||||
```
|
||||
|
||||
## 合并分支
|
||||
|
||||
分支是用来将特性开发绝缘开来的。比如你在本地的test分支新增了一个功能,想要合并到主分支中。
|
||||
@@ -378,6 +422,16 @@ git log --pretty=oneline
|
||||
```
|
||||
git log --name-status
|
||||
```
|
||||
## 生成补丁
|
||||
|
||||
比如你修改了项目中的``fs/proc/base.c``,然后
|
||||
|
||||
```
|
||||
git add fs/proc/base.c
|
||||
git commit -m "fix:base"
|
||||
git format-patch origin/16.0
|
||||
```
|
||||
即可在目录下生成补丁``0001-fix-base.patch``.
|
||||
|
||||
## 删除前一个提交记录
|
||||
有时候手滑或者不想使用一个commit说明,可以用以下命令撤销上一个 commit:
|
||||
|
||||
@@ -383,7 +383,7 @@ sudo update-grub
|
||||
|
||||
除了到VPS后台更换外,还可以使用这个脚本:
|
||||
|
||||
- [bin456789/reinstall](github.com/bin456789/reinstall)
|
||||
[bin456789/reinstall](github.com/bin456789/reinstall)
|
||||
|
||||
```
|
||||
一键重装到 Linux,支持 19 种常见发行版
|
||||
|
||||
Reference in New Issue
Block a user