Day-9 | Git and GitHub | What is GIT ? | What is Version Control ? | #devops #2023 #github #gitlab

Day-9 | Git and GitHub | What is GIT ? | What is Version Control ? | #devops #2023 #github #gitlab

Introduction to DevOps and Version Control

Overview of the Course

  • Abhishek introduces the video as part of a complete DevOps course titled "DevOps Zero to Hero."
  • Viewers are encouraged to watch previous videos in the playlist for better understanding of the topics covered.

Importance of Version Control

  • The concept of version control is introduced as a fundamental aspect of Git and GitHub.
  • Version control systems address two major problems: sharing code and managing personnel changes.

Understanding Code Sharing Challenges

Scenario with Multiple Developers

  • A scenario is presented where two developers (Dev1 and Dev2) work on a calculator application, each responsible for different functionalities (addition and subtraction).
  • Both developers need to share their code to build a common application, highlighting the necessity for effective collaboration tools.

Real-world Complexity

  • In larger organizations, sharing code becomes complex due to numerous files and dependencies, making simple methods like email or Slack inadequate.
  • The challenge escalates when multiple files are modified by different developers, necessitating a structured approach to manage these changes.

The Need for Versioning

Managing Changes Over Time

  • The discussion shifts to versioning, emphasizing its importance in tracking changes made over time.
  • An example illustrates how requirements can change (e.g., from addition of three numbers back to two), necessitating access to previous versions of code.

Tracking Modifications

  • Developers may modify many files daily; thus, keeping track of these changes through versioning is crucial.
  • Effective versioning allows teams to revert back to earlier versions when needed, ensuring flexibility in development processes.

Conclusion on Version Control Systems

Summary of Key Problems Addressed

Understanding Version Control Systems

Introduction to Version Control

  • The speaker discusses the evolution of version control systems, noting that tools existed before Git, such as CVS and SVN.
  • Git emerged as a popular choice due to its design as a distributed version control system, contrasting with earlier centralized systems like SVN.

Centralized vs. Distributed Version Control

  • A common interview question is the difference between centralized and distributed version control systems; understanding this distinction is crucial for developers.
  • In centralized systems (e.g., SVN), developers rely on a single central server for code sharing, which can lead to communication issues if the server goes down.

Communication in Centralized Systems

  • The example illustrates how two developers (Dev1 and Dev2) must communicate through a central server (SVN), limiting their ability to work independently.
  • If one developer wants to share changes, they must upload them to the central server for others to access.

Advantages of Distributed Systems

  • In contrast, distributed version control allows each developer to maintain their own copy of the repository, facilitating independent work and collaboration without reliance on a central server.
  • Developers can create multiple copies of the repository, enabling them to work offline or in case of server failure.

Forking in Git

  • The concept of "forking" is introduced; it refers to creating an entire copy of an original source code repository for personal use or experimentation.
  • This approach ensures that even if the original repository goes down, developers retain access to their own copies.

Limitations of Centralized Systems

  • The speaker emphasizes that centralized systems like SVN and CVS are less favored today due to their vulnerability—if the central system fails, communication between developers halts.
  • Historical context is provided about system administrators managing these repositories on Linux machines and how outages could disrupt development workflows.

Conclusion: Understanding Git's Popularity

  • The discussion concludes by summarizing key differences between centralized and distributed version control systems while highlighting why Git has become more widely adopted than older systems like SVN or CVS.

What is the Difference Between Git and GitHub?

Understanding Git

  • Git is described as a distributed Version Control System, which is open-source software that organizations can download and implement.
  • Organizations can set up their own Git server on an EC2 instance, allowing developers to commit changes to this centralized system.
  • While basic functionality exists with Git, many organizations have identified gaps in usability and have developed better solutions for collaboration.

The Role of GitHub

  • GitHub enhances the basic functionalities of Git by providing improved usability features such as issue tracking, commenting, peer reviews, and project management capabilities.
  • Other platforms like GitLab and Bitbucket also build upon the foundational concepts of Git to offer similar enhancements.

Building Your Own Solution

  • Users can create their own version control systems using open-source versions of Git installed on virtual machines or Linux boxes.
  • The key distinction between tools like GitHub and raw installations of Git is that these platforms provide a user-friendly wrapper around the core functionalities of Git.

How to Create a Git Repository

Initial Setup

  • The speaker demonstrates creating a folder for an example organization (example.com), where they will write code for a simple calculator script.

Installing and Initializing Git

  • To manage versioning, the first step involves installing the command-line tool for git from its official website (git-scm.com).
  • After installation, users can verify successful setup by entering git in the terminal to see available commands.

Basic Commands Overview

  • The command git init initializes an empty git repository within the created folder.
  • Essential commands every developer should learn include:
  • git add: Stages changes for commit.
  • git commit: Records staged changes in the repository history.
  • git push: Uploads local commits to a remote repository.

Understanding .git Directory

Tracking Changes

  • Upon initializing a git repository, a hidden directory named .git is created which contains all necessary files for tracking changes made within that repository.

Key Components of .git

  • Important elements within .git include:
  • Refs: References to commits in your project history.
  • Objects: Actual data representing file contents at various points in time.

Understanding Git: Key Concepts and Commands

Git Objects and Hooks

  • Git objects are essential for version control, allowing tracking of changes in files.
  • The hooks folder in a Git repository can prevent unintentional commits of sensitive information like passwords or API tokens.

Configuration Settings

  • The config file is crucial for setting up Git credentials and managing secure repositories that require secrets or TLS certificates.

Tracking Files with Git

  • Use git status to check the current state of your repository; it will indicate untracked files, such as calculator.sh.
  • To track new files, you must inform Git using the git add command, which tells it to keep track of specific files.

Modifying and Committing Changes

  • After modifying a tracked file (e.g., adding functionality), use git status again to see the changes made.
  • The git diff command shows exact modifications between versions, helping developers understand what has changed in their code.

Version Control through Commits

  • Each change should be committed with a message indicating its purpose (e.g., "this is my first version of addition").
  • After committing changes, use git status to confirm that there are no pending modifications left uncommitted.

Adding New Functionalities

  • When introducing new features (like subtraction), always check the status with git status to ensure all changes are tracked.
  • All actions taken by Git are recorded in the .git directory, which maintains an encrypted history of all project changes.

Finalizing Changes and Viewing History

  • Use commands like git add, followed by committing with messages to maintain clear versioning.

Understanding Git Commits and Versioning

Introduction to Git Commits

  • The speaker introduces the concept of commits in Git, highlighting two specific commits authored by Abhishek: "this is my first commit" and "this is my second version."
  • Emphasizes that Git can track numerous commits, allowing developers to revert to previous versions when necessary.

Navigating Previous Versions

  • To revert to a previous commit, one can use the git log command, which displays all past commits along with their IDs.
  • The speaker demonstrates how to return to an earlier version using the command git reset --hard, confirming the change by checking the contents of a file (calculator.sh).

Versioning Concept in Git

  • Discusses the importance of versioning in software development, enabling users to switch between multiple code versions easily.
  • Mentions that while local repositories are useful for tracking changes, sharing code within teams or organizations requires additional steps.

Sharing Code Using Distributed Systems

Importance of Distributed Systems

  • Introduces distributed systems as essential for sharing code among team members or making it available for open-source projects.
  • Highlights that platforms like GitHub facilitate this process by providing a centralized location for repositories.

Creating a Repository on GitHub

  • Outlines the initial steps required to share code on GitHub, including creating an account and understanding repository ownership.
  • Briefly explains self-hosted git solutions but emphasizes using established platforms like GitHub or GitLab for ease of maintenance.

Steps to Create a Repository

  • Describes how simple it is to create an account on GitHub through straightforward sign-up procedures.
  • Walkthrough includes navigating through options after signing up and selecting "Create a Repository."

Configuring Your Repository

  • Details how users can set up their new repository by choosing templates and naming conventions (e.g., "Abhishek shell example project").

Introduction to Git and GitHub

Initializing a Repository

  • A README file can be initialized to provide metadata about the project, such as its purpose and functionalities (e.g., "This is my first shell scripting program" or "This is a calculator program with four functionalities: addition, subtraction, etc.").
  • After creating the repository, users can either push local changes or directly create files like calculator.sh within the GitHub interface.

Collaboration and Forking

  • Users have the option to create forks of repositories, allowing them to collaborate with other developers while maintaining their own copies of the project.
  • The session emphasizes understanding how GitHub operates, highlighting its popularity compared to other tools like GitLab and Bitbucket.

Deep Dive into GitHub Features

  • Future discussions will cover user management, organization handling, issues tracking, pull requests creation, and CI/CD integration in GitHub.
  • The instructor plans to elaborate on project management features in GitHub during upcoming classes.

Questions and Further Learning

Video description

Join our 24*7 Doubts clearing group (Discord Server) www.youtube.com/abhishekveeramalla/join Udemy Course (End to End DevOps Project) https://www.udemy.com/course/ultimate-devops-project-with-resume-preparation/?referralCode=9F588E43854814744430 --- --- Support my work https://www.buymeacoffee.com/abhishekprd Hi Everyone, Today is Day 9 of Free DevOps course and I am here with a very exciting content. In this class I walk you through Git and Github. We will understand the concept of Version Controlling, Why is GitHub very popular and much more. The script will allow users to retrieve information from GitHub by talking its API, script can be modified to work with any other applications like JIRA, GITLAB and others. Telegram channel =============== https://t.me/abhishekveeramalla About me: ----------------- LinkedIn: https://www.linkedin.com/in/abhishek-veeramalla-77b33996/ GitHub: https://github.com/iam-veeramalla Medium: https://abhishekveeramalla-av.medium.com/ YouTube: https://www.youtube.com/channel/UCnnQ3ybuyFdzvgv2Ky5jnAA?app=desktop . . Disclaimer: Unauthorized copying, reproduction, or distribution of this video content, in whole or in part, is strictly prohibited. Any attempt to upload, share, or use this content for commercial or non-commercial purposes without explicit permission from the owner will be subject to legal action. All rights reserved.