Pull changes from your Git repository on Bitbucket Cloud
- Create a Git repository
- Copy your Git repository and add files
- Pull changes from your Git repository on Bitbucket Cloud
- Use a Git branch to merge a file
Next on your list of space station administrator activities, you need a file with more details about your locations. Since you don't have many locations at the moment, you are going to add them right from Bitbucket.
Step 1. Create a file in Bitbucket
To add your new locations file, do the following:
From your BitbucketStationLocations repository, click Source to open the source directory.
Notice you only have one file,
locations.txt, in your directory.
A. Branch selection: Pick the branch you want to view.
B. Source page: Click the link to open this page.
C. New file button: Edit and create a file in Bitbucket.
D. Source file area: View the directory of files in Bitbucket.
- From the Source page, click New file in the top right corner. This button only appears after you have added at least one file to the repository.
A page for creating the new file opens, as shown in the following image.
A. Branch with new file: Change if you want to add file to a different branch.
B. New file area: Add content for your new file here.
stationlocationsin the filename field .
Select HTML from the Syntax mode list.
Add the following HTML code into the text box:
<p>Bitbucket has the following space stations:</p> <p> <b>Earth's Moon</b><br> Headquarters </p>
Click Commit . The Commit message field appears with the message:
stationlocations created online with Bitbucket.
Click Commit under the message field.
You now have a new file in Bitbucket! You are taken to a page with details of the commit, where you can see the change you just made:
If you want to see a list of the commits you've made so far, click Commits in the sidebar.
Step 2. Pull changes from a remote repository
Now we need to get that new file into your local repository. The process is pretty straight forward, basically just the reverse of the push you used to get the
locations.txt file into Bitbucket.
To pull the file into your local repository, do the following:
Open your terminal window and navigate to the top level of your local repository.
macOS / Linux / Git Bash
$ cd ~/repos/bitbucketstationlocations/
Windows Command Prompt
$ cd repos/bitbucketstationlocations/
git pull --allcommand to pull all the changes from Bitbucket. (In more complex branching workflows, pulling and merging all changes might not be appropriate .) Enter your Bitbucket password when asked for it. Your terminal should look similar to the following:
$ git pull --all
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.
fe5a280..fcbeeb0 master -> origin/master
stationlocations | 5 ++++++++++++++
1 file changed, 5 insertions(+)
create mode 100644 stationlocations
git pullcommand merges the file from your remote repository (Bitbucket) into your local repository with a single command.
- Navigate to your repository folder on your local system and you'll see the file you just added.
Fantastic! With the addition of the two files about your space station location, you have performed the basic Git workflow (clone, add, commit, push, and pull) between Bitbucket and your local system.