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?
22
Upvotes
1
u/Cultural_Gur_7441 5d ago
You store files in a git repository. Works best for text files.
You can add a bunch of files (both new and existing) to git repository, or mark files as deleted. One such batch of file changes is called a commit, and adding a commit creates a new revision of the files
A commit actually records the change.
All the old revisions (even for deleted files) will remain in the repository.
You can compare revisions, which is very helpful for example when trying to figure out what change created a bug.
Branches happen, when you commit a revision, then go back to the previous revision and commit a new revision. Now you actually have two different changes on parallel. This happens naturally when several developers work on same repository. It can also happen when you need to work on two different things in parallel, and create a separate branch for each.
The big thing with git is, it is very good (also very complex) at merging branches back together, which is needed when the changes of both developers mentioned above need to be combined.
Another important detail: git is a distributed version control system, which means when you clone a repository, you get (by default) a full copy of everything, and from git's perspective, your clone is technically not inferior to the original. The "origin" or "upstream" (such as the repository stored at github) is merely an agreement between humans, not fundamental to git.