Bitbucket Cloud で Git リポジトリから変更をプルする
宇宙ステーションの管理アクティビティの次の作業として、場所の詳細情報を含むファイルが必要です。この時点では場所の数があまりないため、Bitbucket から直接追加することになります。
ステップ 1. Bitbucket でのファイルの作成
新しいロケーション ファイルを追加するには、以下の操作を行います。
From your BitbucketStationLocations repository, click Source to open the source directory.
Notice you only have one file,locations.txt
, in your directory.
A. ソース ページ: リンクをクリックしてこのページを開きます。
B. ブランチの選択: 表示するブランチを選択します。
C. その他のオプション ボタン: クリックすると、[ファイルを追加] などのオプションを含むメニューが開きます。
D. ソース ファイル領域: Bitbucket のディレクトリまたはファイルを表示します。
2. From the Source page, click the More options button in the top right corner and select Add file from the menu. The More options button only appears after you have added at least one file to the repository.
次の画像のように、新規ファイルを作成するためのページが表示されます。
A. 新しいファイルのブランチ: 別のブランチにファイルを追加したい場合は変更します。
B. 新しいファイル領域: ここに、新規ファイルのコンテンツを追加します。
3. [ファイル名] フィールドに「stationlocations
」と入力します。
4. [構文モード] リストから [HTML] を選択します。
5. 次の HTML コードをテキスト ボックスに追加します。
<p>Bitbucket has the following space stations:</p>
<p>
<b>Earth's Moon</b><br>
Headquarters
</p>
6. Click Commit. The Commit message field appears with the message: stationlocations created online with Bitbucket.
7. メッセージ フィールドの下の [コミット] をクリックします。
これで、Bitbucket に新しいファイルができました。コミットの詳細を示すページが開いて、先ほど行った変更を確認できます。
ここまでに作成したコミットの一覧を確認したい場合は、サイドバーで [コミット] をクリックします。
ステップ 2. リモートリポジトリから変更をプル
次に、この新規ファイルをローカル リポジトリに送る必要があります。プロセスは非常にシンプルで、基本的に、locations.txt
ファイルを Bitbucket に送る際のプッシュと反対の操作になります。
ファイルをローカル リポジトリにプルするには、次の操作を実行します。
ターミナル ウィンドウを開き、ローカル リポジトリの最上位に進みます。
macOS / Linux / Git Bash
$ cd ~/repos/bitbucketstationlocations/
Windows Command Prompt
$ cd repos/bitbucketstationlocations/
git pull --all
コマンドを入力して、Bitbucket からすべての変更をプルします (より複雑なブランチ作成ワークフローでは、すべての変更のプルやパージが適さない場合があります)。要求されたら Bitbucket パスワードを入力します。ターミナルは次のようになるはずです。$ git pull --all Fetching origin remote: Counting objects: 3, done. remote: Compressing objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From https://bitbucket.org/emmap1/bitbucketstationlocations fe5a280..fcbeeb0 master -> origin/master Updating fe5a280..fcbeeb0 Fast-forward stationlocations | 5 ++++++++++++++ 1 file changed, 5 insertions(+) create mode 100644 stationlocations
git pull
コマンドは、リモート リポジトリ (Bitbucket) のファイルを 1 つのコマンドでローカル リポジトリにマージします。
ローカル システムのリポジトリ フォルダに移動すると、追加したばかりのファイルが表示されます。
素晴らしい!宇宙ステーションの場所に関する 2 つのファイルを追加することで、Bitbucket とローカル システム間の基本的な Git ワークフロー (クローン、追加、コミット、プッシュ、プル) を実行しました。
この内容はお役に立ちましたか?