github 笔记
github 杂记
目录
常用加速与下载
加速下载 github 代码:
- 登录码云
- 新建仓库
- 导入已有仓库,粘贴 github 仓库地址
- 创建后即可直接下载
获取 github token
- 方法一:右上角 → Settings → Developer settings → 选择 github OAuth 或个人访问
- 方法二:登录后直接访问 https://github.com/settings/tokens 或 https://github.com/settings/tokens/new
github token push
https://cxvh:${GITHUB_TOKEN}@github.com/cxvh/blogs.git
git config --global user.name "cxvh"
git config --global user.email "***@qq.com"
发布 github packages
- 初始化 package.json
npm init --scope=cxvh
其中cxvh
必须是你的github用户名,其他随意填写。 - 添加
publishConfig
到package.json
"publishConfig": { "registry": "https://npm.pkg.github.com/" }
- 登录
npm login --registry=https://npm.pkg.github.com/
用户名为github账号,密码用github token,邮箱用github邮箱 package.json
的name
格式为@登录名/包名
,如:@cxvh/hello-world-npm
- 发布
npm publish
github action 配置
根据时间自动构建,官方文档
1 | # ┌───────────── minute (0 - 59) |
push
或 pull_request
触发构建:
1 | on: |
action 克隆到当前仓库示例
1 | name: 每天自动同步仓库 |
报错解决记录
1. 密钥生成失败
- Windows 下执行
ssh-keygen
写入权限不够报错:1
Saving key ".../id_rsa" failed: No such file or directory
- 解决:进入文件夹
C:\Users\用户\.ssh\gitlab
再执行ssh-keygen
2. git rebase 报错
- 历史中不连续的 commit 合并
git rebase -i head~3
,报错如下:1
2
3
4
5
6
7
8
9
10
11interactive rebase in progress; onto bbef1ea
No commands done.
Next commands to do (3 remaining commands):
s ae093ef 更新 circleci 配置文件
s 1ab23ac 更新 circleci 配置文件2
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'main' on 'bbef1ea'.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
nothing to commit, working tree clean - 解决:回到 rebase 执行前状态
git rebase --abort
3. git push 拼写错误
- 错误命令:
git push orgin main
1
2
3
4
5
6
7
8
9
10
11
12fatal: 'orgin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
#
$ git push orgin主要
致命的:“orgin”似乎不是git存储库
致命:无法从远程存储库读取。
请确保您具有正确的访问权限
并且存储库存在。 - 解决:删除
.git
目录,重新git init
并配置远程仓库。
4. git push SSL 报错
1 | fatal: unable to access 'https://github.com/cxvh/cxvh-cli-test.git/': OpenSSL SSL_connect: Connection was reset in connection to github.com:443 |
- 解决:将
https
链接改为ssh
链接git remote set-url origin git@github.com:cxvh/cxvh-cli-test.git
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 BARAN的小站🔥🔥🔥!