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

将GitHub现有仓库复刻至Bitbucket时遇Git操作问题求助

Hey there, let's break down what's going on here and fix it step by step—since you're new to Git, I'll keep things clear and straightforward!

First, let's untangle your messy remote repositories

Looking at your git remote -v output, you've got duplicate remotes pointing to the same GitHub repo, plus a Bitbucket remote named destination—this is why you're getting errors like "remote origin already exists." Let's clean this up first:

# Remove all extra, duplicate remotes
git remote remove another_origin
git remote remove upstream
git remote remove destination

Now run git remote -v again, and you should only see your original GitHub repo listed as origin.

Fix the 403 Forbidden error (Bitbucket permission issue)

That error happens because Bitbucket no longer allows using your regular account password for HTTPS pushes. You need to use an App Password instead:

  1. Log into Bitbucket, go to your Personal Settings
  2. Find the App passwords section, create a new password
  3. Check the "Repository write" permission (and any others you need)
  4. Save this password—you'll only see it once!

Set up your remotes correctly (aligning with Git best practices)

Since you want to "fork" your GitHub repo to Bitbucket, here's the standard way to structure your remotes:

  • origin: Your own Bitbucket repo (the one you're pushing to)
  • upstream: The original GitHub repo (so you can pull updates later if needed)

First, rename your current GitHub remote from origin to upstream:

git remote rename origin upstream

Then add your Bitbucket repo as the new origin:

# Replace YOUR_APP_PASSWORD with the one you just created
git remote add origin https://YOUR_BITBUCKET_USERNAME:YOUR_APP_PASSWORD@bitbucket.org/crowddoingmedicinalfoods/react.git

Push your code to Bitbucket

Now you can push your master branch to Bitbucket with:

git push -u origin master

The -u flag sets up tracking, so next time you just need to run git push origin to sync changes.

Quick note on naming conventions

  • origin is always the repo you own and push changes to (your Bitbucket fork here)
  • upstream is the original repo you forked from (your GitHub repo in this case)

This setup keeps things organized and avoids confusion down the line.

内容的提问来源于stack exchange,提问作者A.P.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:38:31