Version management with Git, GitHub and Co

Git hosting with GitHub and Bitbucket: Creating a repository online

All videos of the tutorial Version management with Git, GitHub and Co
Jan Brinkmann
By Jan Brinkmann Last updated on

Your code is so far only on your own computer. If the hard drive fails or you want to collaborate with others, this quickly becomes a problem. This is exactly where external hosting providers like GitHub and Bitbucket come into play. They store your repositories on a server on the internet, make teamwork easy, and at the same time serve as a backup of your projects.

Version management with Git, GitHub and Co - 12 Git Hosting: GitHub and Bitbucket

The video is only loaded from YouTube when you play it – data (including your IP address) is then transmitted to YouTube/Google. More in the privacy policy

In this guide, you will learn how to create an account on GitHub, create a new repository, set its visibility, and get to know the interface with its most important features. You will also find out how GitHub and Bitbucket differ. You don't need any prior knowledge of Git; I will explain basic terms like repository and commit along the way.

Key Takeaways

A hosting provider is an external server for your Git repositories. It enables teamwork and serves as a backup.

In the free GitHub plan, only public repositories are possible. Private repositories cost money.

Bitbucket offers free private repositories for up to five users and is therefore well suited for smaller teams.

The address (URL) of a repository is the remote host through which you will later upload and download your code.

Issues, labels, pull requests, and wikis help you organize tasks, bugs, and documentation in the project.

Step-by-Step Guide

Step 1: Create an Account on GitHub

The first step is signing up. You only need a user account, and the free account is completely sufficient to get started. After registering, you log in with your credentials. You then land on your personal home page, from which you can reach all further steps.

Git hosting with GitHub and Bitbucket: Creating a repository online

Step 2: Start a New Project

On the interface, you will find the button "Start a project" or "New". With it, you create a new repository. In the example in the video, you enter the name "git-beispiel". Optionally, you can also add a short description that gives the project a clear purpose. Especially when other people see your project later, an understandable description helps enormously.

Git hosting with GitHub and Bitbucket: Creating a repository online

Step 3: Set the Visibility

Next, you choose who may see your repository. With the "Public" option, the repository is visible to everyone and available in the free plan. The "Private" option makes it accessible only to selected people, but on GitHub it costs money. For your first exercises, the public variant is therefore enough. However, you should know that the code is then readable by anyone. Sensitive data such as passwords or access keys therefore never belong in a public repository.

Git Hosting with GitHub and Bitbucket: Creating a Repository Online

Step 4: Create the Repository

With a click on "Create repository", your project is created. GitHub then shows you an address that you should note down or copy. This URL leads directly to your repository on the internet. In addition, GitHub offers a short guide on the page on how to get your code there.

Git hosting with GitHub and Bitbucket: Creating a repository online

Step 5: Two Ways to Upload Code

GitHub essentially distinguishes between two scenarios. In the first case, you don't have a project on your computer yet. Then you create a local repository with the command "git init", create a README file, make your first commit, and then link the whole thing to the online repository with the command "git remote add". In the second case, you already have an existing project. In this case, you skip the initialization and simply add the remote connection. Which way suits you depends on whether your project already exists.

Git hosting with GitHub and Bitbucket: Creating a repository online

Step 6: Use the Address as the Remote Host

You will use the copied URL later as the remote host. It is the connection between your local project and the server. With it, you can upload and download changes. How exactly to set up the connection and synchronize your changes, I will show you in the next part of the series. For the moment, it is enough to know the address and keep it safe.

Git hosting with GitHub and Bitbucket: Creating a repository online

Step 7: Create a README file directly in the browser

You can also create files directly through the web interface without any Git commands. To do so, select the option "Add a README" or "Add file" in the project and create a file named "README.md", for example. Then confirm the process with "Commit new file". The file appears in the repository immediately. This approach is practical for small changes, but for daily work, working with Git on your own computer is recommended.

Git hosting with GitHub and Bitbucket: Creating a repository online

Step 8: Fill the README file meaningfully

In the README file, you describe what the project is about. Useful details include the license, the purpose of the project, or a URL to the documentation. The file is automatically displayed on the repository's home page. A visitor therefore sees right away what to expect. The README file is also often the first point of contact when someone wants to use or support your project.

Step 9: Download the repository and continue working

Via the "Code" button, you can copy the URL and clone the repository to your computer. This gives you a complete copy that you can work on locally. You then put your changes back online. This very cycle of downloading, changing, and uploading is the heart of collaboration with Git.

Step 10: Use issues and labels

Under the "Issues" tab, you manage tasks, bugs, and requests. An issue can be a bug, an enhancement, or a question from a user. With labels, you mark the type of entry by color, for example a bug in red. This way you keep an overview even with many open items, and this applies especially when several people are working on the project.

Git Hosting with GitHub and Bitbucket: Creating a Repository Online

Step 11: Understand pull requests and forks

Pull requests are somewhat more advanced. When another person copies your project via the "Fork" button, they work in their own copy. They can then submit a pull request to merge their changes into your original. This concept is central above all in open-source projects. To begin with, it is enough to know the principle.

Step 12: Explore wikis, insights, and members

Further tabs offer additional overviews. In the wiki, you can store detailed documentation. Under "Insights", you can see, presented graphically, how the commits are developing. In the members area, you manage who is involved in the project. However, you will spend most of your time in the code view, in which all files and directories are visible.

Git hosting with GitHub and Bitbucket: Creating a repository online

Step 13: Get to know Bitbucket as an alternative

Besides GitHub, there is another provider in Bitbucket, which is particularly well known in professional environments and for open-source projects. Bitbucket offers free private repositories for up to five users. If you work with a small team and value private projects, it is worth taking a look at this platform. The basic principles are very similar for both services, so you will find your way around quickly.

Git Hosting with GitHub and Bitbucket: Creating a Repository Online

Step 14: Choose the right provider

Whether GitHub or Bitbucket is the better choice for you depends on your goals. For open-source projects and a large community, GitHub has been the first address for years. If you want to manage private projects for free in a small team, Bitbucket offers an attractive entry point. With an account on GitHub, you are well positioned in any case.

Git hosting with GitHub and Bitbucket: Creating a repository online

Summary ??? Git Hosting with GitHub and Bitbucket: Creating a repository online

You have learned how to create an account on GitHub and set up a public repository. You now know how to distinguish between a new and an existing project and what the repository URL is for. You also know the most important areas of the interface, including issues, pull requests, and wikis. With Bitbucket, you have also gotten to know an alternative that enables free private repositories. In the next step, you will connect your local project to the remote host and learn how to bring changes online.

FAQ

Do I have to pay for GitHub?No, the free plan is sufficient to get started. However, it only allows public repositories.

What is the difference between a public and a private repository?A public repository is visible to everyone. A private repository is accessible only to selected people and is paid on GitHub.

Can I use Bitbucket for free with private repositories?Yes, Bitbucket offers free private repositories for up to five users.

What is a remote host?The remote host is the server on which your repository is located online. It is addressed via the repository URL.

What is an issue?An issue is an entry for a bug, an enhancement, or a question about the project. Labels can be used to mark the type of entry.

What does fork mean?A fork is your own copy of someone else's repository. From there, you can suggest changes by submitting a pull request.

Should I store passwords in a public repository?No, sensitive data such as passwords or access keys do not belong in a public repository, because anyone can view the code.

Jan Brinkmann
Trainer About Jan Brinkmann Web development with passion! Jan has been a developer for over 15 years. All courses by Jan Brinkmann