Форкинг существующего репозитория GitHub в Bitbucket - PullRequest
0 голосов
/ 09 января 2019

У меня возникли проблемы при попытке перенести мой существующий репозиторий GitHub в Bitbucket. Я использовал терминал, чтобы использовать git remote add, как указано в инструкциях, но он продолжал сообщать fatal: the remote origin already exists. Также, когда я пытаюсь толкнуть его, ничего не происходит. Я посмотрел ответы здесь, чтобы изменить имя, но я использовал ссылку GitHub, и ничего не произошло. Я не знаю, правильно ли я назвал мой форк удаленным источником и исходным репо. У кого-нибудь еще была подобная проблема, с которой я столкнулся? Я довольно плохо знаком с тем, как это работает, и до сих пор учусь.

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

1 Ответ

0 голосов
/ 09 января 2019

Проблемы с текущим подходом

$ 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

Это показывает, что вы получили ошибку 403 Forbidden, когда пытались передать в Bitbucket (скорее всего, потому что вы не аутентифицированы для этого). Я не знаком с Bitbucket, но при отправке в репозитории GitHub я использую транспорт SSH, а не HTTPS при настройке URL-адресов удаленного репозитория. Веб-сайт Atlassian предоставляет хорошую документацию о том, как использовать SSH с Bitbucket , поэтому я советую заставить эту часть работать, прежде чем продолжить.

$ 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.

Здесь origin уже был установлен на https://XXX@bitbucket.org/crowddoingmedicinalfoods/react.git, как видно из предыдущей команды git remote -v.


Предлагаемый подход

Вот шаги, которые я бы предпринял, чтобы перейти от одного удаленного хранилища к другому:

# 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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...