リポジトリのクローン

Cloning a repository

Sourcetree、コマンド ラインの Git、または任意のクライアントを使用して Git リポジトリをクローンできます。以下は、ターミナルから Git を使用してリポジトリをクローンする方法の手順です。
  1. リポジトリのグローバル サイドバーで + をクリックして、[作業に取りかかりましょう] の下の [このリポジトリをクローン] を選択します
  2. clone コマンドをコピーします (SSH または HTTPS 形式)。SSH プロトコルを使用している場合、公開キーが Bitbucket に追加されていて、クローンを行うローカル システムに読み込まれていることを確認します。
  3. ターミナル ウィンドウで、リポジトリをクローンするローカル ディレクトリに移動します。
  4. Bitbucket からコピーしたコマンドを貼り付けます。以下に例を示します。

    HTTPS 経由でのクローン:
     $ git clone https://username@bitbucket.org/teamsinspace/documentation-tests.git
    SSH 経由でのクローン:
    $ git clone ssh://git@bitbucket.org:teamsinspace/documentation-tests.git

クローンが成功すると、リポジトリをクローンしたディレクトリのローカル ドライブに新しいサブディレクトリが表示されます。このディレクトリは、クローンした Bitbucket リポジトリと同じ名前になります。クローンには、ソース ファイルに加えた変更を保持するために Git が必要とする、ファイルとメタデータが含まれます。

Cloning a mirror repository

You can use SourceTree, Git from the terminal, or any client you like to clone your Git repository. These instructions show you how to clone a mirrored repository using Git from the terminal. Read more about Smart Mirrors

 

  1. Bitbucket のリポジトリへ移動します。
  2. [クローン] ボタンをクリックします。
  3. If mirrors are configured, use the Clone from dropdown to select the mirror closest to you–the clone URL changes.
  4. Copy the clone URL (either SSH or HTTPS).
    If you are using the SSH protocol, ensure your public key is correctly configured. 
  5. Launch a terminal window.
  6. Change to the local directory where you want to clone your repository.
  7. Enter git clone followed by the copied clone URL.
    The command and clone URL together would look like this:

    $ git clone ssh://git@bitbucket-au.example.com:7999/upstream/PROJ/repo.git

クローンが成功すると、ローカル ドライブに新しいサブディレクトリが表示されます。このディレクトリは、クローンした Bitbucket リポジトリと同じ名前になります。クローンには、ソース ファイルへの変更を保持するために Git が必要とする、ファイルとメタデータが含まれます。

You cannot push to a mirror!

Mirrors are read-only. After cloning from a mirror, you must update your remote push URL to point to the primary Bitbucket Data Center instance.

Update your remote push URL

Since you cannot push to a mirror, after cloning from a mirror you need to update your remote push URL to point to the primary (upstream) instance.

プッシュ URL を更新する方法

  1. In the repository on Bitbucket Server, click the Clone button.
  2. Select a mirror in the Clone from dropdown, then copy the command that looks like this:

    git remote set-url --push origin ssh://git@bitbucket.example.com:7999/PROJ/repo.git

  3. In the terminal, navigate to the cloned directory then run the command.

Your remote push URL now points to the primary Bitbucket Data Center instance.

Update your remote push URL in SourceTree

Since you cannot push to a mirror, after cloning from a mirror you need to update your remote push URL to point to the primary (upstream) instance within SourceTree.

SourceTree で プッシュ URL を更新する方法
  1. Bitbucket Server のリポジトリで、[クローン] をクリックします。
  2. [クローン元] ドロップダウンでミラーを選択してから、次のようなコマンドをコピーします。

    git remote set-url --push origin ssh://git@bitbucket.example.com:7999/PROJ/repo.git

    You won't need the commands, only the push URL (the bit that starts after ssh://).

  3. SourceTree で リポジトリ設定を開きます。
  4. 元のリポジトリ パスを選択してから、[構成ファイルを編集...] をクリックします。
    テキスト エディターが表示されます。 
  5. Within the Config File, under [remote "origin"], enter pushurl = then paste only the push URL after =.
    The config file should look like this:

    pushurl = ssh://git@bitbucket.example.com:7999/PROJ/repo.git
  6. 構成ファイルを保存して閉じます。[OK] をクリックしてリポジトリ設定画面を閉じます。

SourceTree 内のリモート プッシュ URL が、プライマリ Bitbucket Data Center インスタンスをポイントするようになりした。

最終更新日 2017 年 5 月 1 日

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

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