将现有的GitHub存储库分叉到Bitbucket [英] Forking an existing GitHub repo to Bitbucket

查看:79
本文介绍了将现有的GitHub存储库分叉到Bitbucket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难将现有的GitHub存储库分叉到Bitbucket.我使用了终端来使用git remote add,就像在说明中指出的那样,但是它一直在报告fatal: the remote origin already exists.同样,当我尝试推动它时,什么也没发生.我已经查看了此处更改名称的答案,但是我一直在使用GitHub链接,但没有任何反应.我不知道我是否正确地将我的fork远程来源和原始回购称为上游.还有其他人遇到过类似的问题吗?我对这是如何工作还很陌生,并且在此过程中仍在学习.

I am having difficulty trying to fork my existing GitHub repo to Bitbucket. I used the terminal to use the git remote add like it stated on the directions but it kept on reporting fatal: the remote origin already exists. Also when I try to push it, nothing happens. I've looked at the answers on here to change the name, but I have been with using the GitHub link, and nothing happens. I don't know if I properly called my fork remote origin and the original repo upstream. Has anyone else had a similar problem that I'm experiencing? I'm fairly new to how this works and still learning along the way.

git remote add
git remote rm
git push -u origin


$ git init
Reinitialized existing Git repository in /Users/appleuser/Desktop/axios-react/.git/

$ git remote add origin https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git

$ git push -u origin master
remote: Forbidden
fatal: unable to access 'https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git/': The requested URL returned error: 403

$ git clone https://github.com/ItsAntP/axios-react-github.git
Cloning into 'axios-react-github'...
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 27 (delta 5), reused 27 (delta 5), pack-reused 0
Unpacking objects: 100% (27/27), done.

$ git remote -v
another_origin  https://github.com/ItsAntP/axios-react-github.git (fetch)
another_origin  https://github.com/ItsAntP/axios-react-github.git (push)
destination https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git (fetch)
destination https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git (push)
origin  https://github.com/ItsAntP/axios-react-github.git (fetch)
origin  https://github.com/ItsAntP/axios-react-github.git (push)
upstream    https://github.com/ItsAntP/axios-react-github.git (fetch)
upstream    https://github.com/ItsAntP/axios-react-github.git (push)

$ git remote add origin https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git
fatal: remote origin already exists.

$ git push origin master
Everything up-to-date

$ git push -u origin master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Everything up-to-date

推荐答案

当前方法问题

$ git init
$ git remote add origin https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git
$ git push -u origin master
remote: Forbidden
fatal: unable to access 'https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git/': The requested URL returned error: 403

这表明您尝试推送到Bitbucket时收到403禁止错误(很可能是因为您未经身份验证才这样做).我不熟悉Bitbucket,但是当推送到GitHub存储库时,在配置远程存储库URL时,我使用SSH传输而不是HTTPS. Atlassian网站提供了有关如何将SSH与Bitbucket ,因此,我建议在继续操作之前让此部分正常工作.

This shows that you got a 403 Forbidden error when you tried to push to Bitbucket (most likely because you are not authenticated to do so). I’m not familiar with Bitbucket but when pushing to GitHub repositories, I use the SSH transport rather than HTTPS when configuring remote repository URLs. The Atlassian website provides good documentation on how to use SSH with Bitbucket so I’d advise getting this part working before proceeding.

$ git clone https://github.com/ItsAntP/axios-react-github.git
$ git remote -v
another_origin  https://github.com/ItsAntP/axios-react-github.git (fetch)
another_origin  https://github.com/ItsAntP/axios-react-github.git (push)
destination https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git (fetch)
destination https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git (push)
origin  https://github.com/ItsAntP/axios-react-github.git (fetch)
origin  https://github.com/ItsAntP/axios-react-github.git (push)
upstream    https://github.com/ItsAntP/axios-react-github.git (fetch)
upstream    https://github.com/ItsAntP/axios-react-github.git (push)
$ git remote add origin https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git
fatal: remote origin already exists.

在这里,从上一个git remote -v命令可以看到,origin已经设置为https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git.

Here, origin was already set to https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git as can be seen from the previous git remote -v command.

以下是我将要从一个远程存储库更改为另一个存储库的步骤:

Here are the steps, I would take to change from one remote repository to another:

# Change to parent directory (something other than desktop preferably)
cd /Users/appleuser/Desktop/

# Delete current directory.
rm -rf axios-react/

# Clone the GitHub repository into the `axios-react` directory.
# Use the `-o` option to identify the remote repository as `github` rather than `origin`.
git clone -o github https://github.com/ItsAntP/axios-react-github.git axios-react

# Change into the repository directory
cd axios-react

# Now add the URL of the Bitbucket remote repository as `origin`.
git remote add origin https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git

# Ensure that are authenticated with Bitbucket before attempting to push to it.
git push -u origin master

这篇关于将现有的GitHub存储库分叉到Bitbucket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆