Git is the most popular version control system in the world. But this definition may not make sense to all of you. To better understand it, you have to know the following 3 primary things:
- What does it do?
- Why is it so useful?
- Why do people love it?
What does Git do?
Git helps us to manage our project files. And a project could be anything such as website design, development, mobile app development, and anything that is related to programming. But what does Git do that makes it easier to manage our project files?
Well, three main aspects help us manage our project files more easily.
- Feature branches
It simply means that Git keeps track of the changes we make to our files. It could be adding/removing new lines/code, images, files, anything & everything in between that refers to the word “Change.”
For example, you made some changes to your CSS file last April. And for some reason, you need the old CSS. Git’s history can help you in this regard. To do that, you have to look for the previous “commit” and you will find all the changes that you made (including old and new code).
See the screenshots below for more clarifications.
In the above history, the reddish background lines were deleted and new greenish lines are added. The lines in the white background have no changes.
This is what the Git history is.
Without a version control system, it’s not possible to keep track of the changes. Learn more about using Git.
Nothing is ever lost, and nothing is ever final in the version control system.
If you create something on a computer with a team or group of people, there is a common concern to override each one’s progress. That would be a cause of conflict.
However, Git makes this teamwork or collaboration easier than ever. It takes care of merging, conflict & accidentally deleting each other’s progress.
Collaboration allows you to become more productive because you don’t have to wait or sit down for someone else’s progress. After you finish your task, you can push your progress to the repo. And this applies to everyone working on your team. See how you can install Git on your computer.
In a nutshell, when everyone finishes their work and when it comes to merging everyone’s code, Git will take care of merging any conflicts.
Git feature branches:
When you initiate Git (
git init) or create a project or repository, it automatically creates a branch called “master.” But you’re just not limited to creating or using only one branch (master). You can create more branches when needed.
For example, you need to edit a website’s header & sidebar and you need to assign these two tasks to two different team members. In this regard, you can create two different feature branches named “header-changes & footer-changes.” Now the two separate persons can work for these two branches independently.
This way one programmer does not hostage another developer’s work. You can learn more about Git branches in this post.
And each of the developers can merge their code when they finish and Git will take care of the conflict as I discussed in the last section.
To learn more about feature branch workflow, see another article on Atlassian (Bitbucket). If you want to use GitHub as the hosting service, see how to create a repository on GitHub.
Learn more about Git
- What is Git and why it is used?
- How to install Git on Windows & Mac?
- How to use Git with Visual Studio Code?
- How to use Git and GitHub?
- What is the difference between Git and GitHub?
- How to connect local Git to a remote server?
- How to change Git remote origin URL?
- How to create a Git repository on GitHub?
- Git add all (stage all changes)
- How to undo the git add -A command?
- How to undo the last Git commit?
- How to change the git commit message?
- How to remove or unstage a file from Git commit?
- How to git push after rebase?
- Git switch branches: How to checkout the git branch?
- How to merge a git branch to master?
- Git branch: create, checkout, merge, list, command, delete & push
- How to clone a Git repository?
- How to git pull to override the local project?
- How to remove file from Git?
- When should you use git rebase?
- Git commands & explanation (downloadable cheatsheet included)
- How to create GitHub Pages?
Now you have a basic understanding of Git and you know what it is used for. If you’re just getting started, it may look intimidating. But it’s not as hard as it seems.
Sometimes beginners mess up it with GitHub. If this is you, see their differences.
To become familiar with it, you have to make your hands dirty. And there is no other way around it. Also, be sure to check the most commonly used git commands. You’ll also find a downloadable cheat sheet on that post.