#90DaysofDevOps Challenge-Day 8
What is Git?
Git is an open-source distributed version control system. It is designed to handle minor to major projects with high speed and efficiency. It is developed to coordinate the work among the developers. The version control allows us to track and work together with our team members in the same workspace.
Git is the foundation of many services like GitHub and GitLab, but we can use Git without using any other Git services. Git can be used privately and publicly.
With Git, you can keep a record of who made changes to what part of a file, and you can revert back to earlier versions of the file if needed. Git also makes it easy to collaborate with others, as you can share changes and merge the changes made by different people into a single version of a file.
What is GitHub?
GitHub is an immense platform for code hosting. It supports version controlling and collaboration and allows developers to work together on projects. It offers both distributed version control and source code management (SCM) functionality of Git. It also facilitates collaboration features such as bug tracking, feature requests, and task management for every project.
GitHub is a web-based platform that provides hosting for version control using Git. It is a subsidiary of Microsoft, and it offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its features. GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects.
Essential components of GitHub are:
Repositories
Branches
Commits
Pull Requests
Git (the version control tool GitHub is built on)
What is Version Control? How many types of version controls do we have?
Version control is a system that tracks changes to a file or set of files over time so that you can recall specific versions later. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.
There are two main types of version control systems: centralized version control systems and distributed version control systems.
A centralized version control system (CVCS) uses a central server to store all the versions of a project's files. Developers "check out" files from the central server, make changes, and then "check-in" the updated files. Examples of CVCS include Subversion and Perforce.
A distributed version control system (DVCS) allows developers to "clone" an entire repository, including the entire version history of the project. This means that they have a complete local copy of the repository, including all branches and past versions. Developers can work independently and then later merge their changes back into the main repository. Examples of DVCS include Git, Mercurial, and Darcs.
Why do we use distributed version control over centralized version control?
Better collaboration: In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don't have to constantly communicate with a central server to commit their changes or to see the changes made by others.
Improved speed: Because developers have a local copy of the repository, they can commit their changes and perform other version control actions faster, as they don't have to communicate with a central server.
Greater flexibility: With a DVCS, developers can work offline and commit their changes later when they do have an internet connection. They can also choose to share their changes with only a subset of the team, rather than pushing all of their changes to a central server.
Enhanced security: In a DVCS, the repository history is stored on multiple servers and computers, which makes it more resistant to data loss. If the central server in a CVCS goes down or the repository becomes corrupted, it can be difficult to recover the lost data.
Overall, the decentralized nature of a DVCS allows for greater collaboration, flexibility, and security, making it a popular choice for many teams.
Difference between Git and Github:
GitHub | Git |
It is a cloud-based tool developed around the Git tool. | It is a distributed version control tool that is used to manage the programmer's source code history. |
It is an online service that is used to store code and push from the computer running Git. | Git tool is installed on our local machine for version controlling and interacting with online Git service. |
It is dedicated to centralizing source code hosting. | It is dedicated to version control and code sharing. |
It is managed through the web. | It is a command-line utility tool. |
It provides a desktop interface called GitHub Desktop GUI. | The desktop interface of Git is called Git GUI. |
It has a built-in user management feature. | It does not provide any user management feature |
It has a marketplace for tool configuration. | It has a minimal tool configuration feature. |
Create a new repository on GitHub and clone it to your local machine:
On your local machine:
Check whether the git tool is installed on your system, If not then install it.
Git - Installing Git (git-scm.com)
we can check the version:
$ git --version
Make a new directory and enter inside it. Then type the below command to make it a git repository.
$ git init
On GitHub:
Create a GitHub account and login to it. You will find a new repository icon on the right top of the page.
Now we can copy the repo URL:
Now clone the repository by using this command.:
Make some changes to a file in the repository and commit them to the repository using Git:
We need to create a file using Vim editor and we can check the status using the below command.
$ git status
Now we need to add that file to the staging area and check the status:
Then need to commit that file:
$ git commit -m "message"
you can set the user name in the config file.
$git config --global user.name "username"
- Push the changes back to the repository on GitHub:
$ git push <remote> <branch name>
Thank you for reading!!!!!