Learn Git with Bitbucket Cloud (by Atlassian)

This article was sponsored by Atlassian. Thank you for supporting the sponsors who make SitePoint possible.

Objective

Learn the basics of Git with this space themed tutorial.

Mission Brief

Your mission is to learn the ropes of Git by completing the tutorial and tracking down all your team’s space stations. Commands covered in this tutorial:

  • git clone, git config, git add, git status, git commit, git push, git pull, git branch, git checkout, and git merge

Create a Git Repository

As our new Bitbucket space station administrator, you need to be organized. When you make files for your space station, you’ll want to keep them in one place and shareable with teammates, no matter where they are in the universe. With Bitbucket, that means adding everything to a repository. Let’s create one!

  • Some fun facts about repositories
    • You have access to all files in your local repository, whether you are working on one file or multiple files.
    • You can view public repositories without a Bitbucket account if you have the URL for that repository.
    • Each repository belongs to a user account or a team. In the case of a user account, that user owns the repository. + In the case of a team, that team owns it.
    • The repository owner is the only person who can delete the repository. If the repository belongs to a team, an admin can delete the repository.
    • A code project can consist of multiple repositories across multiple accounts but can also be a single repository from a single account.
    • Each repository has a 2 GB size limit, but we recommend keeping your repository no larger than 1 GB.

Step 1. Create the repository

Initially, the repository you create in Bitbucket is going to be empty without any code in it. That’s okay because you will start adding some files to it soon. This Bitbucket repository will be the central repository for your files, which means that others can access that repository if you give them permission. After creating a repository, you’ll copy a version to your local system—that way you can update it from one repo, then transfer those changes to the other.

Git repo

Do the following to create your repository:

  1. From Bitbucket, click Repositories > Create repository button at the top of the page.

    The system displays the Create a new repository page. Take some time to review the dialog’s contents. With the exception of the Repository type, everything you enter on this page you can later change.

  2. Enter BitbucketStationLocations for the Name field. Bitbucket uses this Name in the URL of the repository. For example, if the user the_best has a repository called awesome_repo, the URL for that repository would be https://bitbucket.org/the_best/awesome_repo.
  3. For Access level, leave the This is a private repository box checked. A private repository is only visible to you and those you give access to. If this box is unchecked, everyone can see your repository.
  4. Pick Git for the Repository type. Keep in mind that you can’t change the repository type after you click Create repository.
  5. Click Create repository. Bitbucket creates your repository and displays its Overview page.

Step 2. Explore your new repository

Take some time to explore the repository you have just created. You should be on the repository’s Overview page:

Click items on the Navigation menu to see what is behind each one. To view the shortcuts available to navigate these items, press the ? key on your keyboard.

When you click the Commits option on the menu bar, you find that you have no commits because you have not created any content for your repository. Your repository is private and you have not invited anyone to the repository, so the only person who can create or edit the repository’s content right now is you, the repository owner.

Copy Your Git Repository and Add Files

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. Git refers to copying a repository as "cloning" it. When you clone a repository, you create a connection between the Bitbucket server (which Git knows as origin) and your local system.

Continue reading %Learn Git with Bitbucket Cloud%



Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

TOP