Pull changes from your Git repository on Bitbucket Cloud

このページの内容

  1. Create a Git repository
  2. Copy your Git repository and add files
  3. Pull changes from your Git repository on Bitbucket Cloud
  4. 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:

  1. 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.

  2. 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. 

  3. Enter  stationlocations  in the  filename field .

  4. Select HTML from the Syntax mode list.

  5. 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>
  6. Click Commit . The  Commit message field appears with the message:  stationlocations created online with Bitbucket.

  7. 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:

  1. Open your terminal window and navigate to the top level of your local repository.

    $ cd ~/repos/bitbucketstationlocations/
  2. Enter the  git pull --all  command 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
    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

    The  git pull  command merges the file from your remote repository (Bitbucket) into your local repository with a single command.

  3. 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.

次へ

Last modified on Aug 7, 2017

この翻訳に満足しましたか?

はい
いいえ
この記事についてのフィードバックを送信する

Not finding the help you need?

コミュニティへの質問

Powered by Confluence and Scroll Viewport.