Day-08:Basic Git & GitHub for DevOps Engineers.

Day-08:Basic Git & GitHub for DevOps Engineers.

What is Git?

Git is a mature, actively maintained open-source version controlling tool originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. Version control systems are tools that help a software team manage changes to source code over time. With Git, you can keep a record of who made changes to what part of a file, and you can revert to earlier versions of the file if needed.

What is Github?

GitHub is a web-based platform that serves as a hosting service for software development projects that use the Git revision control system. It provides a place for developers to store and manage their code, collaborate with other developers, and track changes to their code over time. It is owned by Microsoft and is one of the largest code-hosting platforms in the world.

What is Version Control? How many types of version controls we have?

Version control, also known as source control, is the practice of tracking and managing changes to source code over time. It allows developers to keep a history of changes made to code, collaborate with others on a project, and revert to previous versions if necessary. They also enable developers to work on multiple versions of a project simultaneously and merge changes made by different developers into a single codebase.

There are two main types of version control systems:

1. Centralized 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.

    2. Distributed version control systems.

    In DVCS, every contributor has a local copy or 'clone' of the main repository i.e- everyone maintains a local repository of their own, which contains all the files and metadata present in the main repository.Developers can work independently and then later merge their changes back into the main repository. Examples of DVCS include Git, Mercurial, and Darcs.

Why we use distributed version control over centralized version control?

  1. 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.

  2. Branching: DVCS makes it easy to create branches of the repository. Developers can create a branch to work on a new feature or bug fix without affecting the main branch. This makes it easy to experiment with new ideas without affecting the stability of the main branch.

  3. 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.

  4. Flexibility: With DVCS, developers have more flexibility in how they work. They can work on their copy of the repository without affecting others, and they can commit changes whenever they want. This makes it easier to work on multiple features or bug fixes at the same time.

*Create a new repository on GitHub and clone it to your local machine

Step-1:- Create a new repository in GitHub.

Step-2 :- Create a directory with the same name in the local machine.

Step-3 :- Copy the HTTPS code from github.

Step-4 :- Clone the url of GitHub on your local machine.

*Make some changes to a file in the repository and commit them to the repository using Git.

git status: Shows the status of your file.

git add: Adds the file to staging area.

git commit: Commits all the staged files to the local repository.

*Push the changes back to the repository on GitHub.

git remote -v: Shows the remote origin url.

git push origin main: Pushes all the local changes to remote branch.

file1.txt has been pushed to github.

\>>>>>>>>>>>>>>>>>> Thank you for reading! :-) <<<<<<<<<<<<<<<<