Recently, I encountered an issue while trying to push changes to a Bitbucket repository after migrating to a new workspace and repository structure. The original Git remote was pointing to an outdated URL, and I needed to update it to reflect the new location. Here’s how I resolved the issue.
❌ The Problem
When trying to push to the remote, Git threw the following error:
remote: The requested repository either does not exist or you do not have access. fatal: unable to access 'https://bitbucket.org/old_user/old_repo.git/': The requested URL returned error: 403
This happened because the Git remote was still pointing to:
https://bitbucket.org/old_user/old_repo.git
But the correct repository is now under a new workspace:
https://new_user@bitbucket.org/new_workspace/new_repo.git
✅ The Solution
- Check the current Git remote:
git remote -v
- Update the remote URL:
git remote set-url origin https://new_user@bitbucket.org/new_workspace/new_repo.git
- Verify the change:
git remote -v
You should see the new URL listed for both fetch and push.
- Push your changes:
git push origin main
(Replace
main
with your actual branch name if needed.)
🔐 Authentication Tips
If you still get a 403 error, it might be due to authentication. Bitbucket now requires App Passwords for HTTPS access instead of your account password.
To create an app password:
- Go to Bitbucket App Passwords
- Generate a new password with
repository:read
andrepository:write
permissions - Use your Bitbucket username and the new app password when prompted by Git
✅ Done!
With the remote updated and authentication handled correctly, Git should now push to the new repository without issues.
Tip: You can avoid entering your password every time by caching Git credentials or switching to SSH for authentication.
Comments
Post a Comment