What is Git?
Git stands for Global Information Tracker. It is a type of version control system which track changes to files and coordinate work on those files among multiple people. It is commonly used for software development, but it can be used to track changes to any set of files.
What is Github?
GitHub is a web-based platform built on top of Git, the distributed version control system. It provides a centralized service for hosting, managing, and collaborating on Git repositories. GitHub simplifies the use of Git by offering a user-friendly interface, collaboration tools, and additional features like issue tracking, continuous integration, and project management
What is Version Control? How many types of version controls we have?
Version control is a system that records changes to files over time so that you can track, manage, and revert to previous versions of your code or documents. It allows multiple people to work on a project simultaneously, keeps a history of changes, and facilitates collaboration.
Version control is particularly useful in software development, where changes are frequent, and collaboration is essential. It ensures that no work is lost, conflicts are minimized, and the development process remains organized.
There are two types of version control system :
Central Version Control System : The files are stored in a single central server. Team members check out files, make changes, and then commit them back to the central repository. Files being stored in a single server makes it easy for teams to collaborate and push the changes. The disadvantage of central version control system is dependency on central server. If the server goes down or is unavailable no one can access your repository. Ex : Subversion (SVN)
Distributed Version Control System : Each developer has a complete copy of the entire repository, including its history. Changes are made locally and can be pushed or pulled to/from other repositories. The advantage of this version control system is it facilitates branching, merging, and collaboration and it is not dependent on central server for making changes. Ex: Git
Why we use distributed version control over centralized version control?
Feature | CVCS | DVCS |
Server Dependency | Always required | Not required for most operations |
Offline Support | Limited | Full |
Speed | Slower (network-dependent) | Faster (local operations) |
Data Loss Risk | High if server fails | Low (multiple copies of repo) |
Branching and Merging | Costly and less efficient | Lightweight and efficient |
Collaboration | Requires central server | Direct peer-to-peer or server-based |
Scalability | Limited (central server bottleneck) | High (distributed architecture) |
When to Use Distributed Version Control
Teams with distributed or remote developers.
Projects with large codebases or frequent branching and merging.
Open-source projects or those requiring flexible collaboration.
Organizations prioritizing speed, reliability, and resilience.
When to Use Centralized Version Control
Smaller teams working on simple projects.
Projects with strict access control requirements.
Organizations with existing infrastructure and expertise in centralized systems.
Exercises:
- Create a new repository on GitHub and clone it to your local machine
Login into github.com and click on ‘New’ under repositories
Mention the repository name and other details
Click on new file and add a file for testing
clone the git repo into your local machine
- Make some changes to a file in the repository and commit them to the repository using Git and push the changes back to repository on git hub
In this question, we had created a repo in github and then cloned the repo in our local ubuntu machine using command git clone “repo url”
In github repo we had created a file with a single line and then we added a new line into it after it was cloned to local server and it was pushed to the remote repo in github.
Commands used
git init
git clone “repo url”
git commit -m "Commit message"
git push origin “branch name”