
在进行 vibe coding 时容易在项目推送环节翻车比如大家常调侃的将 API 密钥推送到仓库的情况。本文就为大家讲清楚 DeepSeek API 如何安全推送。摘要本文详细介绍了在 vibe coding 过程中如何安全地将项目推送到 GitHub避免泄露 API 密钥等敏感信息。文章从推送前的安全检查开始逐步讲解 Git 仓库初始化、代码提交、远程推送等完整流程并提供了更新现有仓库的方法和常见问题解决方案。通过本文您可以掌握安全推送代码的最佳实践确保开发过程中的信息安全。前置检查推送前先确认项目根目录没有敏感信息API Key 等# 搜索是否有真实 API Key类似 sk- 开头的密钥 grep -r sk-[a-zA-Z0-9]\{20,\} . --include*.py --include*.json --include*.md --include*.txt 如果没有任何输出说明没有硬编码的密钥初始化仓库# 进入项目目录 cd D:\项目文件所在 初始化 Git 仓库 git init 确认 .gitignore 已正确排除敏感文件和缓存 .gitignore 中应该至少包含 .claude/ pycache/ *.pyc .pytest_cache/ cat .gitignore提交代码# 暂存所有文件 git add . 确认只有代码文件被暂存没有 .claude/、pycache 等 git status 提交到本地仓库 git commit -m init: minimal agent from scratch 将 master 分支改为 mainGitHub 默认分支名 git branch -M main推送到 GitHub# 关联远程仓库替换为你的仓库地址 git remote add origin https://github.com/你的用户名/你的仓库名.git 推送到 GitHub git push -u origin main更新已存在的仓库如果仓库已存在只需要提交新改动cd D:\agent-main\demo 暂存所有变动 git add . 查看变动内容确认无误 git status 提交 git commit -m 描述你的改动 推送 git push常见问题问题解决fatal: remote origin already existsgit remote set-url origin https://github.com/用户名/仓库名.gitpush rejected远程有新增提交git pull --rebase origin main后再git push误提交了敏感文件git rm --cached 文件名并更新.gitignore后重新提交