push
提交 source 并推送到 git remote。
如果你只想要一个不推送的本地检查点,请改用 commit。
skillshare push # 自动生成消息
skillshare push -m "Add pdf" # 自定义消息
skillshare push --dry-run # 预览
何时使用
- 通过 git 与你的其他机器共享 skill 更改
- 将你的 skills 备份到远程仓库
- 编辑 skills 后,一条命令完成提交并推送
如果你想先保存一个本地检查点而暂不共享,请使用 skillshare commit。
会发生什么
选项
| 标志 | 描述 |
|---|---|
-m, --message <msg> | Commit 消息(默认:"Update skills") |
--dry-run, -n | 预览而不做任何更改 |
Git Root 作用域
push 作用于 git_root 配置字段所选定的目录(默认:skills source)。作用域表参见 commit — Git Root Scope。如果 git_root 被更改了,但 git 仓库仍然位于另一个作用域的目录中,push 会打印一条 "Git root mismatch" 错误,并给出精确的 git init / mv 命令来修复。参见 Changing the scope after init。
前提条件
你的 source 目录必须是一个带有 remote 的 git 仓库:
# 在 init 期间设置(推荐):
skillshare init --remote [email protected]:you/my-skills.git
# 或为现有设置添加 remote:
skillshare init --remote [email protected]:you/my-skills.git
Init 会自动创建初始 commit,因此设置完成后 push 可立即使用。
首次 Push 的 Upstream 映射
在首次 push 时(尚未有 upstream tracking),skillshare push 会自动配置 upstream:
- 如果 remote 已经有默认分支(例如
main或trunk),本地更改会被推送到该 remote 默认分支。 - 如果 remote 为空,则会推送到你当前的本地分支。
这样可以避免意外创建错误的 remote 分支(例如本地是 master 而 remote 使用 main)。
示例
# 使用自动生成消息快速推送
skillshare push
# 自定义 commit 消息
skillshare push -m "Add commit-commands skill"
# 预览将要推送的内容
skillshare push --dry-run
冲突处理
如果 remote 有更新的 commit:
$ skillshare push
Push failed
Remote may have newer changes
Run: skillshare pull
Then: skillshare push
解决方法:
skillshare pull # 获取 remote 的更改
skillshare push # 推送你的更改
工作流
共享 skills 的典型工作流:
# 1. 对 skills 进行更改
# 2. 推送到 remote
skillshare push -m "Update my-skill"
# 在另一台机器上:
skillshare pull # 获取更改并同步
另请参阅
- commit — 仅提交,不推送
- pull — 从 remote 拉取
- sync — 同步到本地 targets
- Cross-Machine Sync — 完整设置