Sourcetree ブランチを使用して更新をマージする
宇宙総合メール マガジンを見て、宇宙ステーションで使いたいスピーカーを見つけたとします。大音量を出力でき、無重力状態でぶつかっても問題ないような柔らかいものです。唯一の問題は非常に高額という点です。そのため、備品のリストに正式に追加する前に、承認が必要となります。
待っている間に、リクエスト リストの備品を追加できるよう、フィーチャー ブランチを作成します。承認を受けたら、フィーチャー ブランチからメイン ブランチにリクエスト ファイルをマージします。
Branches are most powerful when you're working collectively with your colleagues. You can work on your own part of a project from your own branch, pull updates from Bitbucket, and then merge all your work into the main branch when it's ready. Our documentation includes more explanation of why you would want to use branches.
ステップ 1: ブランチの作成と変更
ブランチを作成して、備品のリクエスト ファイルにスピーカーを追加しましょう。
From Sourcetree, select the Branch button.
[新しいブランチ] または [新しいブランチの作成] フィールドで、ブランチの名前に「
wish-list」と入力します。Select Create Branch or OK.
From Sourcetree, select the Show in Finder button. The directory on your system opens.
ディレクトリ フォルダで、テキスト エディタを使って
supplyrequestファイルを開きます。次のアイテムを備品のリストに追加することで、ファイルに変更を加えます。
<li>anti-gravity speakers</li>ファイルを保存する。
Sourcetree でビューを開くと、リポジトリに未コミットの変更があることがわかります。
ここで、
supplyrequestファイルを追加して最初にコミットしたときと同じ操作を実行します。Git リポジトリがある場合は、
supplyrequestをコミットできるよう、オプション メニューで [ファイルをステージングする] を選択します。Select the Commit button at the top to commit the file.
メッセージ ボックスに、「Adding an item for my wish list (ウィッシュ リストにアイテムを追加する)」と入力します。
Select the Commit button under the box. From Sourcetree, you see that the file has been updated on the
wish-listbranch.
ステップ 2. ブランチからファイルの変更をマージする
スピーカーが承認されました。次に、メインの備品リストで wish-list アイテムを更新します。
まず、メイン ブランチに戻ります。Sourcetree の左側のメニューで [ブランチ] ラベルの右側にカーソルを動かすと、[表示] という単語が表示されます。
When Show appears, select it.
Under the Branches heading, you will see the two branches for this repository, the main branch, and thewish-listbranch.メイン ブランチをダブルクリックすると、そのブランチに切り替わります。
[マージ] ボタンを選択します。
表示されるポップアップで、
wish-listブランチのコミットがハイライト表示されていることを確認します。これは、このブランチのコミットをメイン ブランチに追加するように指定していることを意味します。Git リポジトリがある場合は、下部にあるオプション [fast-forward でマージが解決された場合もコミットを作成する] を選択します。
[OK] を選択します。
wish-list のアイテムでメイン ブランチのsupplyrequestファイルを更新しました。以上で完了です。
ステップ 3. 変更を Bitbucket へプッシュ
From Sourcetree, select the Push button to push your committed changes.
From the dialog box that appears, select the OK button to push changes to your local repository.
Select the Overview page of your Bitbucket repository, and notice you can see your push in the Recent Activity stream.
Select Commits and you can see the commit you made on your local system. Notice that the change keeps the same commit code that it had on your local system.
Select Source , then select the
supplyrequestfile. You can see the last change to the file has the commit code you just pushed.Select the file history list to see the committed changes for this file, as shown in the following image.
完了です!
大変な作業でした。おそらく、宇宙へロケットを打ち上げる際と比べたら大したことはないでしょう。これで Bitbucket について多くを学び、宇宙ステーションの活動をはるかにうまく実行する準備が整いました。では、少し休憩して、星空を眺めましょう。
Want to learn more about Bitbucket and Sourcetree? You can take on the challenge of updating a colleague's repository.
この内容はお役に立ちましたか?