Git & GitHub for DevOps Engineers(part-1)

Git & GitHub for DevOps Engineers(part-1)

Today, we're going to take a deep dive into Git and GitHub, two of the most essential tools for modern software development and collaboration.

What is Git & Why is it Important?

Git is a distributed version control system that allows developers to track changes to their codebase. It's vital for a few reasons:

  1. Version Control: Git keeps track of every change made to a project, creating a history that enables you to revisit past states of your code.
  2. Collaboration: Git facilitates team collaboration by allowing multiple developers to work on a project simultaneously.
  3. Backup and Recovery: It provides a safety net. If something goes wrong or you lose your code, Git allows you to recover previous versions.

Branching and Merging: Git enables the creation of branches for developing features, and these branches can later be merged back into the main project.

What is Github?

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

What is Version Control? How many types of version controls 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.

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

What is the difference Between the Main Branch and the Master Branch??

In Git, the main branch and the master branch essentially refer to the same thing: the default branch of your repository. Historically, "master" was used, but many projects are now switching to "main" due to potential connotations of the term "master." The choice between the two largely depends on your project's naming convention, and both are widely accepted.

How do you create a new repository on GitHub?

  1. Log In to Your GitHub Account: Open your web browser and go to GitHub. Log in to your GitHub account if you haven't already.
  2. Access Your Dashboard: Once you're logged in, you'll land on your GitHub dashboard. You can access it by clicking on the GitHub logo in the top left corner.
  3. Create a New Repository: On your dashboard, you'll find a green button labeled "New" in the top right corner. Click on it to start creating a new repository.
  4. Set Up Your New Repository: You'll be taken to a new page where you can fill in the details for your repository:Repository Name: Choose a unique and descriptive name for your repository.Description (Optional): Add a brief description of your repository.Visibility: You can choose between Public and Private. Public repositories are visible to everyone, while Private repositories are only visible to you and collaborators.Initialize this repository with: You can choose to add a README file, a .gitignore file, or a license. These are optional but can be helpful.

Exercises solution

  1. Create a new repository on GitHub and clone it to your local machine
  2. Make some changes to a file in the repository and commit them to the repository using Git

hetvi@20 Desktop % git clone https://github.com/hetvi20/github-test-repo.git        

3. Push the changes back to the repository on GitHub :


Thank you for reading I hope you like it!!

For Advance Git & GitHub for DevOps Engineers : Part 2 Click here


Stay in the loop with my latest insights and articles on DevOps by following me on LinkedIn (https://www.dhirubhai.net/in/imhetvishah).

Thank you for reading! Your support means the world to me. Let’s keep learning, growing, and making a positive impact in the tech world together.

要查看或添加评论,请登录

Hetvi Shah的更多文章

社区洞察

其他会员也浏览了