SuperAPI AI Directory

git-push

Coding & development

View repository

Updated 10-16 02:58

About this skill

One-click push to GitHub

Feature description

Push the current project to GitHub with one click, covering the complete lifecycle:

  • First push — a new project from zero to GitHub
  • Daily update — files changed, just push (commit + push)
  • Version release — tag + create Release, optionally with downloadable files

Core principles:Safety first. Better to ask one extra question than to push something that shouldn't be pushed.


Workflow

Step 0: Environment check + mode determination

Check the prerequisites in order; if any is not met, stop and provide guidance:

1. Is git installed

  • ❌ → Prompt:brew install git, stop
  • ✅ → Continue

2. Is gh CLI installed

  • ❌ → Prompt:brew install gh, stop
  • ✅ → Continue

3. Is gh logged in to GitHub

  • Run gh auth status to check
  • ❌ Not logged in → Prompt:gh auth login, stop
  • ✅ Logged in → Record the account name, tell the user "Current logged-in account: [xxx]", and continue

4. Is git user information configured

  • Run git config user.name and git config user.email to check
  • ❌ Not configured → Prompt the user to set:
    git config --global user.name "你的名字"
    git config --global user.email "你的邮箱"
    
    Stop
  • ✅ Configured → Continue

5. Is the current directory already a git repository → determines which path to take

不是 git 仓库 → 【首次推送】从第1步开始
是 git 仓库,无 remote → "本地有 git 但没关联远程"
    → 先执行第1步的大文件扫描(确保安全)
    → 再跳到第2步关联远程
是 git 仓库,有 remote → 【已有仓库】进入模式选择:
    ├── "推日常更新" → 跳到第3B步(日常更新)
    ├── "发新版本"   → 检查是否有未提交的变更
    │   ├── 有变更 → 先走第3B步,再走第4步
    │   └── 无变更 → 直接跳到第4步(只打 tag + Release)
    └── "重新来"
        → ⚠️ 警告:"这将删除所有 Git 历史记录(包括所有提交、分支、tag),不可恢复。"
        → 用户二次确认后删除 .git,从第1步开始

Step 1: Project scan + .gitignore generation

⚠️ Iron rule: .gitignore must be in place before the first git add . Never commit first and exclude later — large files in Git history cannot be cleanly removed, which will bloat the repository and cause push failures.

1.1 Scan directory sizes

Use du -sh to scan all top-level directories and files, sorted by size.

Handling large files by tier:

Size Handling method
>10MB List them and ask the user one by one, "Push this?"
>50MB Additional warning "It is relatively large, pushing will be slower"
Single file >100MB Must be excluded, GitHub hard limit, cannot be pushed

Display format(example):

扫描发现以下内容超过 10MB:

  1. 109MB  slides/   (PPT + 大图片)
  2.  12MB  assets/   (视频文件)

⚠️ 其中 slides/ 超过 50MB,推送会很慢。
❌ 其中 recording.mp4 (150MB) 超过 GitHub 100MB 单文件限制,必须排除。

要排除哪些?(输入序号,或 "全部排除" / "全部保留")

1.2 Sensitive content scan (public repositories only)

If the user chose a public repository, additionally scan:

  • .env / .env.* — environment variables/secrets
  • *secret* / *credential* / *token* — key files
  • *.pem / *.key — certificate files
  • memory/ / MEMORY.md — AI tool memory files
  • Any file that looks like private content

List the suggested exclusions and have the user confirm each one.

1.3 Generate or update .gitignore

If .gitignore does not exist: generate a new file based on the scan results.

If .gitignore already exists: read the existing content, merge in the new exclusion items, and show the diff for the user to confirm. Do not overwrite the user's existing rules.

Basic template:

# macOS
.DS_Store
.AppleDouble
.LSOverride
._*

# Editor
*.swp
*.swo
*~
.vscode/
.idea/

# [以下根据扫描结果动态生成]
# 大文件(用户确认排除)
[路径1]
[路径2]

# 敏感内容(仅公开仓库时)
[路径3]

Show to the user for confirmation, then write to the file.


Step 2: User decision

1. Repository name(Default: current directory name)

2. Description(One sentence, can be left blank)

3. Public / Private

  • Public → Second confirmation: "Public repositories are visible to everyone. Confirm that .gitignore has excluded sensitive content?"
    • Not confirmed → Go back to Step 1.2 (sensitive content scan) and re-review, then return to this step to continue

4. Check for a repository with the same name

  • Execute gh repo view [账号]/[仓库名] to check
  • ❌ Does not exist → Continue
  • ✅ Already exists → Tell the user, ask:
    • "Use a different name" → Re-enter
    • "Use this existing repository" → Skip creation, directly associate the remote (record the repository URL for use in Step 3)
    • "Delete and recreate" → Requires second confirmation from the user

Step 3: Push

3A. First push (new project)

Strictly follow this order:

1. git init + git branch -m main
2. git add -A
3. git commit -m "init: 初始化 [仓库名]"
4. 创建远程仓库(如果第2步中仓库不存在):
   gh repo create [仓库名] --private/--public --description "[描述]" --source=. --remote=origin
   (如果第2步中用户选了"用已有仓库",跳过创建,直接:git remote add origin [已有仓库URL])
5. git push -u origin main

3B. Daily updates (existing repository)

1. 扫描变更:git status 查看改了什么
2. 检查新增大文件:
   - 新增文件中有 >10MB 的 → 问用户确认
   - 新增文件中有单文件 >100MB → 必须排除,加入 .gitignore
   - 如果修改了 .gitignore,确保 .gitignore 本身也在后续的 git add 范围内
3. git add -A
4. git commit -m "[根据变更内容自动生成提交信息]"
   - 提交信息规则:简洁明了,一句话概括主要变更
   - 示例:"update: 新增用户模块 + 修复登录 bug"
5. git push

Push failure handling

Error Cause Handling
rejected (fetch first) or non-fast-forward The remote has commits that the local does not By default, execute git pull --rebase then retry
Still fails / remote has conflicts Incompatible history Ask the user "Force overwrite the remote?" ⚠️ Inform: "This will overwrite all remote content; use only when you are sure the remote content can be discarded" → git push --force
Timeout/stuck Network issue or repository too large Check the repository size; recommend excluding large files and retrying
Authentication failed Token expired Prompt gh auth login
file exceeds 100MB Single file exceeds limit Prompt with the specific file name, add it to .gitignore, and commit and push again
git add or git commit failed File anomaly/missing configuration Display the error message and guide the user to troubleshoot

Step 4: Optional — Version release (Release)

Trigger timing

  • After the first push, proactively ask once "Do you need to create a version?"
  • After daily updates,do not proactively ask(to avoid interrupting)
  • The user proactively says "release a version", "make a release", "make a tag"

Process

1. Determine the version number

读取当前已有的 tag(git tag --sort=-v:refname | head -5)

├── 没有任何 tag → 建议 v0.1.0
└── 已有 tag → 显示最近的版本,建议下一个(默认 minor +1)
    - v0.1.0 → 建议 v0.2.0
    - v1.2.3 → 建议 v1.3.0
    - 用户可自定义输入任意版本号

版本号说明(供用户参考):
- v0.1.0 → v0.2.0  小更新(加了功能、改了内容)
- v0.2.0 → v1.0.0  大里程碑(首次正式发布、重大重构)
- v1.0.0 → v1.0.1  修修补补(修了个 bug)

2. Release notes

  • Automatically read the commit records since the last tag (git log [上个tag]..HEAD --oneline)
  • Generate a change summary and let the user confirm or modify it
  • If this is the first version (no historical tag), generate the summary using all commits

3. Whether to attach downloadable files

需要附带可下载文件吗?(如 App 安装包、工具压缩包等)

├── 不需要 → 只打 tag + 创建 Release 页面
└── 需要 → 用户提供文件路径
    └── 检查文件是否存在 → 不存在则提示重新输入

4. Execute

git tag [version]
git push origin [version]
gh release create [version] --title "[仓库名] [version]" --notes "[Release 说明]"
# 如果有附件:
gh release upload [version] [文件路径]

Release failure handling:

  • Tag already exists → Prompt the user "This version number is already in use" and ask the user to choose another one
  • Attachment file does not exist → Prompt to re-enter the path
  • Other errors → Display the error message

Completion output

✅ 推送完成!

- 仓库:[URL]
- 可见性:私有 / 公开
- 文件数:[N] 个
- 仓库大小:[X]
- 排除项:[列出被 .gitignore 排除的内容]
- Release:[版本号 + URL] / 未创建

Core principles

1. Scanning comes before everything

.gitignore on the first git add is already in place. Once a large file enters Git history, even if it is later deleted, the repository size will not shrink, which will cause push failures or extreme slowness. Projects that already have git but are not linked to a remote must also be scanned before pushing.

2. Proactive large-file interception

Proactively ask the user for files 10MB and above. Warn that files 50MB and above are slow, and that a single file of 100MB is GitHub's hard limit and must be excluded.During daily updates, also check the size of newly added files.

3. Double-check public repositories

For public repositories, additionally scan for sensitive content (keys, AI memory files, private documents), and confirm a second time before pushing.

4. Do not break existing content

If the project already has .git or .gitignore, do not overwrite by default; ask the user first. Destructive operations such as deleting .git must clearly warn about the consequences and require a second confirmation.

5. Every step can be interrupted

The user can say "stop" or "go back to the previous step" at any time. Do not run through everything in one go without giving the user a chance to react.

6. Daily updates should be lightweight

Daily updates do not ask about Release, do not ask about the repository name, and do not rescan the entire project. Only check newly added large files, commit + push, and get in and out quickly.


Usage examples

Scenario 1: First push of a new project

用户:帮我推到 GitHub

Skill:
→ 检查环境:git ✅ gh ✅ 已登录 ✅ git 用户已配置 ✅ 不是 git 仓库
→ 扫描项目...发现超过 10MB 的内容:
  - 85MB slides/ → 用户确认排除
  - 15MB images/ → 用户确认保留
→ 生成 .gitignore,用户确认
→ 仓库名:my-project,私有
→ 初始化 + 推送成功
→ "需要打 Release 吗?" → 跳过
→ ✅ 完成

Scenario 2: Daily update

用户:推一下

Skill:
→ 检测到已关联远程仓库
→ 扫描变更:修改 3 个文件,新增 2 个文件(均 <10MB)
→ 提交信息:"update: 新增用户模块 + 更新配置文件"
→ 推送成功
→ ✅ 完成

Scenario 3: Release a version

用户:打个 release

Skill:
→ 当前最新 tag:v0.1.0
→ "建议下一个版本号 v0.2.0,可以吗?"
→ 自动生成变更摘要(基于 commit 记录)
→ "需要附带下载文件吗?" → 不需要
→ 创建 tag + Release
→ ✅ Release v0.2.0 发布成功!

Scenario 4: A large file is found during push

→ git push 失败:file recording.mp4 exceeds 100MB
→ "recording.mp4 (150MB) 超过 GitHub 限制,需要排除"
→ 加入 .gitignore,重新提交推送
→ ✅ 成功

Scenario 5: A large file is newly added during a daily update

用户:推一下

→ 扫描变更...发现新增文件:
  - demo.pptx (25MB)
→ "这个文件 25MB,确认要推吗?"
→ 用户确认排除 → 加入 .gitignore
→ 推送成功
→ ✅ 完成

Scenario 6: Release a version but there are no new changes

用户:打个 release

→ 当前没有未提交的变更,直接进入版本发布
→ 当前最新 tag:v0.2.0
→ "建议 v0.3.0,可以吗?"
→ 用户自定义输入 v1.0.0
→ 生成变更摘要 + 创建 Release
→ ✅ Release v1.0.0 发布成功!