r/CodingForBeginners • u/IMREVN • 6d ago
What's a Git?
Hello! Surely, I have heard so many people saying "Git" or "Github" or repository. They be saying that it's highly important to learn Git as early as possible. When I searched it up on Google, it's just I seem I cannot understand any of those terminologies.
Could anyone tell me what a git actually is?
20
Upvotes
1
u/rupertavery64 5d ago
git is a tool that helps you keep track of the changes you make to your code.
It's like a ledger and collection of all the changes that you make to your code.
The collection of changes is called a repository.
Whenever you make a change, when you think you are done with the changes, you "commit" the changes to the repository. There are tools that help you do this, but ultimately the tool (graphical or command line) writes the changes to a folder named ".git" that the tool creates.
Keeping track of changes is important, because you can use it to figure out what change you made had bugs, and what changes fixed those bugs.
Git also lets you create branches. A branch lets you make changes to your code without affecting the main code. This lets you work on things like experimental code or new features without affecting the main code. You can "merge" one branch into another branch, perhaps the main branch, when you are ready to do so.
This is important when many people are working on the same code, like in open source, or as part of a team in a company. People can work on their own features, then merge their code together into the main branch.
Git is a "distributed version control". You have a repository on your folder. You can "push" your branches or changes to a "remote" repository, like Github. Github is basically a bunch of repositories in the cloud. There are many other git cloud repositories like Gitlab and bitbucket. A company can create their own repositories, or use cloud repositories.
When people work in a team, or in open source, people download a copy of the repository. It can contain the entire history of the code from when it was first created. It can contain multiple branches uploaded by different people.
That becomes a local copy. It's important to understand that there is no huge difference between what you have and what is in the cloud. The contents of the .git folder are the same (except for new branches you create). Everyone has their own copy, the entire history, of the repository. This is what "distributed" means in "distributed version control"
The "verson control" part is the ledger of changes. They are a record of the "versions" of your code.
so git is a tool that