You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows本地用Cloud SDK向GCP云源仓库推送代码报.git不存在错误

报错根本原因是当前本地工作目录未初始化为Git仓库,gcloud init及全局凭据配置命令不会自动生成本地仓库的.git目录,按以下步骤操作即可解决:

操作步骤
  • 第一步:在Cloud SDK终端中切换到存放index.html的本地工作目录,执行Git初始化命令
git init

执行完成后当前目录会自动生成.git隐藏文件夹

  • 第二步:将index.html加入暂存区并提交首次版本记录
git add index.html
git commit -m "首次提交:新增index.html"
  • 第三步:绑定远程Cloud Source Repository
git remote add google https://source.developers.google.com/p/la-gcp-test/r/demo-repo
  • 第四步:将本地提交推送到远程仓库
git push google main

如果你的本地默认分支命名为master,将最后一步命令替换为git push google master即可

内容的提问来源于stack exchange,提问作者Nishit Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 21:36:08