What is Git?
Git is a distributed version control system that allows you to track changes in your codebase over time, collaborate with other developers on the same codebase, and manage different versions of your code. It was created by Linus Torvalds in 2005 and has since become one of the most widely used version control systems in the world.
Git works by creating a local repository on your computer, where you can make changes to your code and commit them to the repository. You can then push those changes to a remote repository, such as on a server or hosting service like GitHub, where other developers can access the code and make changes of their own. Git allows you to merge changes from different branches of code, compare different versions of files, and revert to previous versions if necessary.
What is GitHub?
GitHub is a web-based hosting service for version control using Git. It provides a platform for developers to collaborate on code and manage projects. It was founded in 2008 and acquired by Microsoft in 2018.
GitHub allows users to create repositories, which can be thought of as folders that contain code files, and track changes to those repositories using Git. These repositories can be made public or private, and users can collaborate on code with other developers by creating and merging branches of code.
GitHub also plays an important role in the open-source community, where developers can contribute to open-source projects hosted on GitHub, and companies can share their code with the wider community. GitHub has become an essential tool for developers and is widely considered to be one of the most important platforms for software development today.
What is Version Control? How many types of version controls do we have?
Version control is a system that manages changes to a file or set of files over time so that you can track the history of the changes and revert back to earlier versions if necessary. It is an essential tool for software development, where multiple developers work on the same codebase, and changes need to be tracked, reviewed and merged.
There are two main types of version control systems:
Centralized Version Control Systems (CVCS) CVCSs have a central repository that stores all versions of the files, and developers must connect to the central server to access the latest version of the code. Examples of CVCSs include Subversion (SVN) and Perforce.
Distributed Version Control Systems (DVCS) DVCSs allow developers to create a local copy of the entire repository, including all version history. This allows developers to work offline, commit changes to their local repository, and later synchronize those changes with the central repository. Examples of DVCSs include Git and Mercurial.
Both types of version control systems have their advantages and disadvantages, but in recent years, distributed version control systems such as Git have become more popular due to their flexibility, ease of use, and ability to work offline.
Why we use distributed version control over centralized version control?
There are several reasons why distributed version control systems (DVCS) like Git are preferred over centralized version control systems (CVCS) like Subversion. Some of the key reasons are:
Offline work: With DVCS, developers can work offline and commit changes to their local repository without needing to be connected to a central server. This is especially useful for developers who work remotely or need to work in areas without reliable internet access.
Faster operations: DVCSs tend to be faster than CVCSs, especially for operations like branching and merging, because they don't need to communicate with a central server.
Better collaboration: DVCSs make it easier for developers to collaborate on code because each developer has a complete copy of the codebase, including all version history. This makes it easier to work on different parts of the codebase simultaneously and merge changes back into the main codebase.
Flexibility: DVCSs are more flexible than CVCSs, as they allow for more complex workflows and branching strategies. This can be especially important for larger projects with many contributors and complex codebases.
Overall, while centralized version control systems still have their advantages, distributed version control systems have become increasingly popular due to their flexibility, speed, and ease of collaboration.
TASKS
- Create a new repository on GitHub and clone it to your local machine
- Make some changes to a file in the repository and commit them to the repository using Git
- Push the changes back to the repository on GitHub
Here you can see the file in the central repository