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

如何将GitHub master分支仓库内容推送至Bitbucket非master分支

操作步骤
  • 本地克隆GitHub端的目标仓库,进入仓库目录
git clone git@github.com:<GitHub用户名>/<仓库名>.git
cd <仓库名>
  • 为本地仓库添加Bitbucket端的仓库作为新远程源,此处以远程源命名为bitbucket为例
git remote add bitbucket git@bitbucket.org:<Bitbucket用户名>/<Bitbucket仓库名>.git

如果之前已经添加过同名远程源,可执行git remote set-url bitbucket <Bitbucket仓库地址>更新地址。

  • 拉取GitHub端master分支的最新内容,保证本地代码为最新版本
git pull origin master

默认克隆后origin远程源对应GitHub仓库地址,可执行git remote -v核对

  • 将本地master分支内容推送到Bitbucket端的非master目标分支,若Bitbucket端不存在该分支,推送会自动创建。假设Bitbucket端目标分支名为github_sync,执行命令:
git push bitbucket master:github_sync

命令规则为git push <Bitbucket远程源名> <本地分支名>:<Bitbucket端目标分支名>,可根据实际需求修改Bitbucket端的目标分支名称

后续持续同步操作

如果需要定期将GitHub master的更新同步到Bitbucket对应分支,依次执行以下命令即可:

  • 切换到本地master分支:git checkout master
  • 拉取GitHub端最新内容:git pull origin master
  • 推送到Bitbucket目标分支:git push bitbucket master:<Bitbucket端目标分支名>
注意事项

推送前请确认Bitbucket端的目标非master分支没有未同步的独立提交,若有建议先拉取该分支内容合并后再推送,避免覆盖已有改动。
所有仓库地址可根据自己的使用习惯替换为HTTPS地址,命令逻辑不受影响。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.29 13:24:00