Copy your repository and add files
- Create a Git or Mercurial repository
- Copy your repository and add files
- Pull changes from your repository on Bitbucket
- Use Sourcetree branches to merge an update
Now that you have a place to add and share your space station files, you need a way to get to it from your local system. To set that up, you want to copy the Bitbucket repository to your system. Sourcetree refers to copying a repository as "cloning" it. When you clone a repository, you create a connection between the Bitbucket server and your local system.
Step 1. Clone your repository to your local system
Use Sourcetree to clone your repository to your local system without using the command line.
As you use Bitbucket more, you will probably work in multiple repositories. For that reason, it's a good idea to create a directory to contain all those repositories. So start by creating a directory on your local system and call it
From Bitbucket, go to your BitbucketStationSupplies repository.
- Click the Clone button in the top right corner.
Bitbucket displays the Clone this repository dialog.
- From the Clone this repository dialog, click Clone in Sourcetree.
From the Clone New dialog box, update the Destination Path to
<local directory>/repos/bitbucketstationsupplies. This destination path refers to the directory you just created with the folder for the repository. The Name field remains the same with the folder name of the repository.
Click the Clone button.
Congratulations! You've cloned your repository to your local system.
Step 2. Create a file, add it locally, and push it to Bitbucket
With the repository on your local system, you can start making a list of all the supplies you need for your space station. To do so, let's create a file for your supplies.
As you work on this section, the images may look slightly different, depending on whether you are working with a Git or Mercurial repository.
bitbucketstationsuppliesrepository in Sourcetree and notice that there is nothing to commit from your local repository to the remote repository.
Use a text editor to add the following three lines:
space ice cream nerf darts telescope light shield
Save the file as
bitbucketstationsuppliesdirectory on your local system. The
supplies.txtfile now appears in Sourcetree since you created it in your local repository.
Now is the point where you prepare a snapshot of the changes before committing them to the official history. From the options menu of the
supplies.txtfile, select Stage file (for a Git repository) or Add file (for a Mercurial repository).
- Click the Commit button at the top to commit the file.
- In the message box, enter "Initial commit."
Click the Commit button under the box. Your new file is now committed to the project history.
Up until this point, everything you have done is on your local system and is invisible to your Bitbucket repository until you push those changes to your remote Bitbucket repository.
From Sourcetree, click the Push button to push your committed changes. Pushing lets you move one or more commits to another repository, which serves as a convenient way to publish contributions.
From the dialog box that appears, your next step depends on whether you are using Git or Mercurial:
Git–Under the Push? column, select the master branch to indicate that you are pushing that branch to origin and click OK.
- Mercurial–Everything is automatic, so all you have to do is click OK.
Go to your BitbucketStationSupplies repository in Bitbucket.
If you click Commits in the sidebar, you'll see your commit in the repository. Bitbucket combines all the things you just did into that commit and shows it to you.
If you click Source in the sidebar, you'll see your file in the repository, the
supplies.txtfile you just added.