Learn Git from scratch
Hello! Welcome
Today we will learn about Git from scratch!
What is Git?
Git is a version control system that helps you keep track of changes in your files.
It’s ideal for
- Keeping a history of all modifications
- Working in teams
How does Git work?
Git keeps a history of all the changes you make to your files.
At any time, you can look at previous versions and see what has changed over time.
It’s like a hyper-vitaminized Control-Z!
Installing GIT
To install GIT, follow these steps:
- Go to the official page git-scm.com.
- Download the installer for your operating system (Windows, Mac, or Linux).
- Follow the installation instructions. It’s very simple!
You’re doing great!
Now let’s talk about concepts and fundamentals
Repositories
A repository is a place where Git stores your project and its history.
You can have:
- Local repositories on your computer
- Remote repositories on services like GitHub (the remote is optional)
Making changes
When you make changes to the project files, you need to tell Git what you want it to do with them.
For example,
- To tell Git you want to track a file, use
git add .
- When you want to confirm the changes, you will make a
commit
This creates a record of your changes in the repository.
Working with branches
Branches are independent versions of a project where you can work on new features without affecting the main version (master)
When you have finished your changes, you can merge them with the main branch
Resolving conflicts
When working in a team, sometimes code conflicts occur. This happens if two people change the same part of the code.
Git helps you resolve these conflicts. However, sometimes human intervention will be necessary to decide how to combine the code
You’re almost there!
We just need to see team collaboration thanks to Git
Team collaboration
Git facilitates collaboration by allowing multiple people to work on the same project.
For example, several people on a team can work on the same repository and use Git to merge their code
Remotes
Remote repositories are versions of your project that are stored on an online server.
- Clone: To copy an existing repository (
clone
) - Pull changes: To get the latest changes (
pull
) - Push changes: To send your changes (
push
)
GitHub and other services
GitHub, GitLab, and Bitbucket are platforms that host remote repositories.
They offer additional tools for collaboration and project management.
All of them have a free tier and a paid tier (with additional features)
Start using Git!
Now that you have the basics, start using Git to manage your projects. With practice, you will become an expert in version control.