Distinguish Between Local and Remote Repositories
First things first: do you fully understand what a repository is?
Local Repositories
A local repository is your project’s virtual storehouse. It allows you to save code versions and access them as needed.
Think of it like making a cake, following these steps:
Prepare and bake the cake mix.
Store it in the fridge.
Whip up some buttercream and assemble the cake.
Store the assembled cake in the fridge.
Decorate the cake.
Put it back in the fridge.
In this example, the fridge is like a local repository: it’s the place where you store what you’ve created as you go along.
A local repository is used in the same way! You create a version, which you’ll work on and improve over time. These versions are stored as you go along in the local repository.
Remote Repositories
Remote repositories are slightly different. They allow you to store the different versions of your code to maintain a remote history, i.e., a history hosted on the internet or a network. You can have several remote repositories with different permissions (read-only, read-write, etc.).
In this way, even if your PC gives up on you tomorrow, you’ll still have all your hard work saved in a remote repository! For this reason, I’d always recommend starting by copying your source code to a remote repository when you start a new project, using GitHub, for example. You can also make it public so that different people can add their developments to it.
Therefore, a remote repository is a must-have if you’re working with other people on a project, as it allows you to centralize the work done by each developer. This is also where the changes made by each person are merged.
So why create a local copy?
Your local repository is a clone of your remote repository. This is where you make all your changes to the code.
Repositories are useful if:
You want to keep track of your project history.
Several people are working together.
You want to contribute to open-source projects.
You need to know who has made each change.
You need to know why each change was made.
Choose the Right Platform to Host Your Code
There are several useful tools for this (GitHub, GitLab, Bitbucket), and we’re going to look at the main pros and cons of each of them.
GitHub
This is secretly my favorite, but don’t tell anyone! GitHub is a tool that allows developers (or anyone involved in writing text) to communicate and work together. It’s a web interface created to make it easier to interact with Git.
One advantage of GitHub is that for a few years now, developers have been using it as their portfolio. During the recruitment process, you’ll often find that you’re asked to provide a link to your GitHub account. That’s one strong argument in GitHub’s favor! It allows you to showcase the quality of your code when you’re looking for a job and demonstrate your skills and the value you bring. GitHub is now considered a sort of social network that allows you to contribute to open-source projects. It works on a subscription basis, but don’t worry; there’s a free option that is also very good.
GitLab
Since GitHub was taken over by Microsoft, GitLab has been the main alternative. The anti-Microsoft crowd even launched the hashtag #MovingToGitLab! GitLab provides a free version that can be hosted by Gitlab itself or on your servers. There are also paid versions with more options.
Bitbucket
Bitbucket is Atlassian’s version. You’ll like it if you’re used to managing projects in Atlassian. Bitbucket is just as good for students as it is for small teams or large groups. A free version is available.
Which one do you prefer? In this course, we’ll be studying GitHub, which is most widely used by developers.
Let’s Recap!
A repository is like a file that maintains a history of versions and changes to a project. It’s essential for working on a team or on open-source projects.
A local repository is a place on your computer where you can store a copy of a project, its different versions, and a record of changes.
A remote repository is an online version of a local repository on the internet or a network. It’s used to centralize developers’ work in collective projects.
There are many online services for hosting remote repositories, and GitHub is one of the most popular.
Now let’s get to work and start our GitHub project!