If you’re just getting started with programming then you’re in the right place. This article is for you! Knowing how to find your way around GitHub is the first step to creating your portfolio of projects and collaborating with other programmers. Don’t worry! With us, you will go through this process quickly and pleasantly. Let’s start from the beginning by explaining what Git and GitHub are.
Git is a version control system that allows developers to save all the changes to the developed code in such a way that they don’t lose anything. A programmer can go back to a previous version at any time if needed. Thanks to the preview of earlier versions, it is possible to trace how the program developed, recover accidentally lost changes or go back to earlier ideas. Great, huh?
Git is used both by developers in teams of large companies and by individuals working independently. It is common to have several people in a company working on the same program at the same time. What could happen if they weren’t using a version control system? In the case that two programmers edit the same file in parallel on their computers, one of them could overwrite the file uploaded to disk by the other. The effects of their work would be lost. Git allows you to manage your team in such a way as to avoid such conflicts.
You can use Git locally by having a local repository on your computer that no one else has access to. Or you can share your code with others – most often co-workers. That is made possible by GitHub, a service that hosts repositories and makes them available to others. GitHub is, therefore, a tool to facilitate teamwork, with version control at the same time.
Well, it’s time to set up your first repository!
Step 1. Create a GitHub account
A Github account is completely free. If you are a student, Github offers you a lot of additional benefits, and all you have to do is apply for the Student Developer Pack.
Step 2. Personalization
In Github, you can customize tools that can be helpful to you, depending on what purpose you are creating the account for. If you would like to collaborate on a project with your friends, the “Collaborative coding” option will make it easier. However, if you were thinking about more professional use for example in software development, you would reach for the “Automation and CI/CD” option. Continuous Integration (CI) is about frequently appending (integrating) current code changes to the main repository and automatically verifying the changes by building the project (if needed) and performing unit tests. For our purposes, the first option will be fully sufficient. You can also skip the customization process and move on.
Step 3. Create your first repository
If you have successfully gone through the account registration steps, you probably have a landing page in front of you. It’s worth taking a look at because you can find a lot of valuable information for beginners there. However, we will focus on setting up the repository itself. You can do this in several ways, and the simplest is to click “Create repository” or “Create project”.
You will then hit the configuration window for your repository where you can decide if your project will be private or public. A private repository allows only you and your collaborators to access the code. A public repository will be visible to all other GitHub users. This is also a good option if you are creating a project that is part of your portfolio, which you will later use during the hiring process.
Click Create Repository. Don’t worry about changing any other options on this page. Remember that these settings can be easily changed at any time during development.
Step 4. Create and add a file
Congratulations! You have set up your first repo on GitHub. If you’d like to add your first code files there right now, feel free to import them from your computer. You can also create a new file directly in GitHub.
Each time you add a new file or make changes to existing code (it can be one or many files) and you want them to be in your GitHub repository you have to define a commit message. It is a short piece of information about the changes you’ve made to the code. The commit must have a proper structure. To learn more about good commit message practices, please keep an eye on our blog for upcoming articles.
Step 5. Write a good README file
Now let’s go back a little bit to the step after creating the repository. If you chose the “Add a README file” option, a readme file is automatically added to your repository. Did you notice this? It’s a good idea to know what the README file is so that you can look there first when browsing other developers’ projects. Often you will find there a valuable introduction to someone else’s project. It may also contain a lot of other important information that the author wanted to convey about his or her code. That’s why it’s crucial that you, in your README file, also clearly describe what is in your project, what was the purpose of your project, and what potential problems someone might encounter when using your code.
You are probably wondering how the use of git looks like in big companies. Maybe I won’t surprise you if I say that professionals in their work use a terminal for this. It is a tool that allows direct communication with a computer. Thanks to it, developers can conveniently and regularly version their changes in the code. Soon we will provide another part of our article series about git. There you will learn how to work with git via terminal, which commands are commonly used, and what they mean. Stay tuned for the next part!