リモート URL をリポジトリに変更する

To change the remote URL for a repository, you'll need to update the configuration file with the new URL. Otherwise, you'll get an error when attempting to push your repository. If you don't want to edit the configuration file, you can also clone the repository from the new location. If you clone, be aware that you'll lose any changes you made but had not pushed to Bitbucket before the transfer!

リポジトリに使用する URL は、HTTPS または SSH のどちらのプロトコルを使用しているかによって異なります。これらの URL は、リポジトリの [ソース] ページの [クローン] ボタンで確認できます。

SSH プロトコルと HTTPS プロトコルのリンクを交互にクリックすることで URL の違いを確認できます。下の表は、プロトコルに基づくフォーマットの違いを示しています。

URL の一部として次の名前が表示されます。

  • <repo_name> にはリポジトリ名が表示されます。

  • HTTPS URL 形式の場合、<workspace_ID> にはワークスペースのワークスペース ID が表示されます。


Git リポジトリ URL
HTTPS 形式https://<your_username>@bitbucket.org/<workspace_ID>/<repo_name>.git
SSH 形式

git@bitbucket.org:<workspace_ID>/<repo_name>.git

または

ssh://git@bitbucket.org/<workspace_ID>/<repo_name>.git


Git リポジトリの URL を更新する

  1. ターミナルでリポジトリに移動します。

    $ cd ~/<path_to_repo>
  2. 現在のリモート URL を表示するには、git remote -v を実行します。

    $ git remote -v
    origin https://emmap1@bitbucket.org/tutorials/tutorials.git.bitbucket.org.git (fetch)
    origin https://emmap1@bitbucket.org/tutorials/tutorials.git.bitbucket.org.git (push)
  3. 現在のリモート URL と新しいリモート URL を使用して、リモート URL を git remote set-url で更新します。

    $ git remote set-url origin git@bitbucket.org:tutorials/tutorials.git.bitbucket.org.git

HTTPS から SSH に URL を更新すると、次にリポジトリからプッシュまたはプルを行ったときに、ターミナルは、Bitbucket ホストを既知のホストのリストに追加することを応答します。また、パスワードを入力する必要はありません。

最終更新日: 2020 年 10 月 5 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.