Imagine you're playing Jenga -- thinking through each move, removing one block at a time. Suddenly, you opt to grab a piece at the base. Consequently, the structure comes tumbling down.
Now the tower must be reassembled, which involves restacking over 50 pieces.
Now imagine that, every time you code, you have to play this game. You make a syntax mistake, or use the wrong crutch, and the whole thing collapses. And you have no idea where you went wrong.
At such moments, you wish you could roll the code back to a state where it functioned correctly, and skip the part where you stack those 50 pieces all over again — every time you mess up.
That is where the Git version control system (VCS) comes in.
What is Git
Jenga in Git might have been set up differently. The game would become a project with files or a repository, in Git terms.
It stores all the actions performed in the game, and all the code files during the development.
To start the game, you have to create a “my Jenga” folder on the computer and initialize a repository in that folder. That is how the repository is created.
As a result, the players have two versions of the game: one local and one tracked by Git. Now the Git repository will always be up to date.
Let’s get back to the game. Git saves every committed change. The save point of the project is called a commit.
A single commit stores information about added, edited, and deleted code files. Commits break up a development process into steps.
It is recommended to include no more than 10 changes in a commit. If something happens, you can roll back with minimal losses.
A chain of commits makes up a branch. Branching helps to solve specific problems without interfering with the main line of development.
For example, a player cannot place the Jenga blocks in a way that the tower does not collapse - another player already took this task, while the others were thinking about the next design. In Git, everyone would solve their task in a separate branch.
After the code review, all successful player actions will be saved in the master branch. This is the foundation version of the project. When the project is done, the master branch will become a complete product.
How Git differs from GitHub
Beginners often confuse Git and GitHub because the names are similar. But Git is not GitHub.
GitHub is a platform that uses Git. GitHub works with Git files.
The web platform stores all repositories and branches. And the code in GitHub looks clearer and easier to understand than in the console.
A developer performs the following actions:
- Plugs in Git
- Signs up on GitHub
- Creates an online repository
- Moves files from Git to GitHub
Git and GitHub are two parts of a single project engine.
An active GitHub account with high-quality code is a must-have when you’re looking for a job.
Sometimes developers use Git without GitHub. They keep the code and work on the project together with other collaboration tools such as GitLab, and BitBucket. GitHub, however, is the most popular choice.
Why you need Git
Git is the most popular VCS. Developers use it for inner peace and convenience.
In a future job, you will work in Git too. You will create a repository with branches, commits, and code.
With Git, a beginner can create personal projects that can be included in a portfolio. Over time, you can track your progress and see what you can improve on.
Git helps you experiment with different ideas and develop your know-how without harming the project.
How to learn Git
To understand the basics of Git, it is worth starting with interactive games and resources.
Non-commercial games help you understand the VCS while playing and doing tasks simultaneously. Examples include Oh my Git!, TwilioQuest and Learn Git Branching.
There are also visualization tools for understanding Git, such as Git Immersion, and Tutorial by Bitbucket. The latter illustrates working with multiple branches.
How to develop your skills
Git is a complicated tool. At first, you will most likely be confused and not understand what to do. That’s natural. Understanding and experience are achieved through trial and error.
In fact, not all experienced developers are Git power users. Many of them don’t know most of the commands by heart. They google them. So don’t be shy about your knowledge gaps — they say nothing about you as a specialist.
You don’t need a deep knowledge of the system to begin using it — only the basic commands.
For example:
- git init — create a new repository
- git status — check for changes in the branch
- git add . — index all changes
- git commit -m “commit” — to commit changes
- git push — push commit to a remote branch
- git pull — pull changes from a remote branch to your local branch
Learn these commands, they will help you get started on your first project.
And remember: you will do great!
Get a career in IT
At TripleTen, you can become a software engineer after ten months of learning with us! Career coaching helps you find a job. And if you don’t get a job within six months of graduating , you will get 100% of your tuition back.