Get started with Bitbucket Cloud
New to Bitbucket Cloud? Check out our get started guides for new users.
After looking through the Intergalactic Mall Magazine, you see a pair of speakers that you really want for the space station. They are big enough to produce a good amount of sound and soft enough that the lack of gravity won't cause them to crash. The only problem is that they are pretty pricey, and you need approval before you can officially add them to your list of supplies.
In the meantime, create a feature branch so that you can update the supply to your request list while you wait. Then when you have approval, you just merge the requests file from the feature branch into the main branch.
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.
Let's create a branch so that you can list the speakers in your supply requests file.
From Sourcetree, click the Branch button.
From the New Branch or Create a new branch field, enter wish-list for the name of your branch.
Click Create Branch or OK.
From Sourcetree, click the Show in Finder button. The directory on your system opens.
From the directory folder, open the supplyrequest file with a text editor.
Making a change to the file by adding the following item to the list of supplies:
<li>anti-gravity speakers</li>
Save the file.
Open the view in Sourcetree and notice that your repository now has uncommitted changes.
From here, everything you do is the same as you did when you added the supplyrequest file and initially committed it.
If you have a Git repository, make supplyrequest ready to commit by selecting Stage file from the options menu.
Click the Commit button at the top to commit the file.
In the message box, enter "Adding an item for my wish list."
Click the Commit button under the box. From Sourcetree, you see that the file has been updated on the wish-list branch.
Your speakers were approved! Now it's time to update the main supply list with your wish-list item.
First, you want to switch back to the main branch. From the left-side menu items in Sourcetree, hover your mouse over the right side of the Branches label so that the word Show appears.
When Show appears, click it.
Under the Branches heading, you will see the two branches for this repository, the main branch, and the wish-list branch.
Double-click the main branch to switch to that branch.
Click the Merge button.
From the popup that appears, make sure the commit on your wish-list branch is highlighted. You are indicating that you want to add the commit from this branch to the main branch.
If you have a Git repository, check this option at the bottom: Create a commit even if merge resolved via fast-forward.
Click OK.
You have updated the supplyrequest file in your main branch with your wish-list item.
You are done.
From Sourcetree, click the Push button to push your committed changes.
From the dialog box that appears, click the OK button to push changes to your local repository.
Click the Overview page of your Bitbucket repository, and notice you can see your push in the Recent Activity stream.
Click 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.
Click Source , then click the supplyrequest file. You can see the last change to the file has the commit code you just pushed.
Click the file history list to see the committed changes for this file, as shown in the following image.
That was intense! Maybe. Depends on how it compares to launching into space. Now that you know a lot more about Bitbucket, you are now prepared to run your space station's activities a lot better. Now, take a break and go do some star gazing.
Want to learn more about Bitbucket and Sourcetree? You can take on the challenge of updating a colleague's repository.
Was this helpful?