Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git and GitHub Mastery: A Collaborative Coding ...

Git and GitHub Mastery: A Collaborative Coding Experience

Avatar for Simar Preet Singh

Simar Preet Singh

March 11, 2024
Tweet

More Decks by Simar Preet Singh

Other Decks in Technology

Transcript

  1. ~whoami 1. I am Simar Preet Singh. 2. Software Engineer

    (FE) at Redaptive Inc. 3. Total Industrial Experience: 6 years. 4. Expertise in: Angular, Reactjs, Nodejs, Firebase, MongoDB, OpenAI Tools… etc. 5. Organiser of Google Developer Groups Jalandhar. 6. Mentor, Speaker and Contributor at Tech Events.
  2. Agenda 1. Introduction to Version Control Systems 2. Introduction to

    Git 3. Basic Concepts of Git 4. Getting Started with Git 5. Introduction to GitHub 6. How to Use GitHub 7. Collaborating with Git and GitHub 8. Best Practices and Tips 9. Why Use Git and GitHub? 10. Q&A
  3. What is Version Control? • A system that records changes

    to a file or set of files over time. • Allows reverting files or projects to a previous state. • Enables comparison of changes over time, identification of last modifications, and understanding of issues' origins.
  4. Importance of Version Control in Software Development • Collaboration: Facilitates

    multiple people working on the same project without conflict. • Backup and Restore: Offers the ability to jump back to any point in the project's history. • Track Changes: Provides visibility on who made changes, when, and why. • Branching and Merging: Supports diverging from the main development line to develop features or fix bugs independently.
  5. Types of Version Control Systems • Local VCS: Basic and

    prone to errors; involves manual copying of files into a different directory. • Centralized VCS (CVCS): Has a single server for all versioned files and multiple clients that check out files, e.g., CVS, Subversion. • Distributed VCS (DVCS): Clients fully mirror the repository, including its history. Examples include Git and Mercurial. Offers robust data integrity and collaborative flexibility.
  6. Definition and History of Git • Definition: Git is a

    distributed version control system designed to handle everything from small to very large projects with speed and efficiency. • History: Developed by Linus Torvalds in 2005 for Linux kernel development. Created to improve upon the weaknesses of other VCS tools and to support distributed, non-linear workflows in an efficient manner.
  7. Key Features of Git • Speed: Git is designed for

    performance. Committing, branching, merging, and comparing past versions are all optimized for speed. • Data Integrity: Every file and commit is checksummed and retrieved by its checksum at any time. This ensures the integrity of your code history. • Distributed Workflows: Allows multiple developers to work together on the same project without any central repository. Each developer's copy of the codebase is a complete version control repository. • Support for Non-linear Workflows: Git supports rapid branching and merging, and includes tools for visualizing and navigating a non-linear development history.
  8. Why Git is Preferred Over Other Version Control Systems •

    Flexibility in Workflow Choices: Git allows for various workflows - centralized, feature branch, Gitflow, and Forking workflows, among others. • Robust Branching and Merging: Making and merging branches is a straightforward and fast process. • Better Performance: Git is significantly faster than most other version control systems, making it ideal for modern development practices. • Widespread Adoption: Its popularity makes it easier to find integrations, tools, and community support. • Works Well with Large Projects: Git's performance doesn’t degrade as the project size grows, making it suitable for both small and large projects.
  9. Repository (Local and Remote) • Local Repository: A database on

    your computer where Git stores the changes to your project. Contains all of your project's files and the history of changes made to those files. • Remote Repository: A version of your project hosted on the internet or network, allowing for collaboration. Changes are pushed to and pulled from remote repositories.
  10. Commit, Branch, Merge • Commit: A snapshot of your repository

    at a specific point in time. Commits include a message describing the changes and allow you to track the history of your project. • Branch: A separate line of development. Branches allow you to diverge from the main line of development, work on new features, or fix bugs, then merge those changes back into the main project. • Merge: The process of combining changes from different branches. Merging integrates the histories of the branches, resulting in a single unified history.
  11. The Workflow (Working Directory, Staging Area, Repository) • Working Directory:

    The local directory on your computer where your files live. You make changes to your files in the working directory. • Staging Area: An intermediate area where Git tracks changes; also known as the index. Changes can be added to the staging area from the working directory and then committed to the repository. • Repository: The .git directory inside your project. It stores all of your commits and the history of your project, tracking changes to the project over time.
  12. Installation of Git • Download Git from git-scm.com. • Follow

    the installation guide for your operating system (Windows, macOS, Linux).
  13. Setting up Git • Configure User Name: Set your user

    name with command git config --global user.name "Your Name" • Configure Email: Set your email address with command git config --global user.email "youremail@example.com" • This information is used in your commits.
  14. Creating Your First Git Repository (repo) • Choose a Project.

    • Initialize Repository git init • First commit git add filename or git add . git commit -m “my first commit”
  15. Basic Git Commands • init: Initialize a new Git repository.

    • add: Add file changes to your staging area. • commit: Save your staged changes along with a commit message explaining what you've done. • status: Check the status of your changes as compared to your last commit. • log: View the chronological commit history for the current branch.
  16. GitHub: A Cloud-based Hosting Service • Hosts Git repositories in

    the cloud, providing a web-based interface for project management. • Facilitates code sharing and publishing within teams or publicly across the global developer community.
  17. Key Features of GitHub • Collaboration: Simplifies team collaboration on

    projects with tools like pull requests, code review, and branch management. • Issue Tracking: Offers a comprehensive issue tracking system that integrates directly with your projects, allowing for bug tracking, feature requests, and task management. • GitHub Actions for CI/CD: Automates your workflow from code to deployment. Build, test, and deploy your code right from GitHub.
  18. GitHub vs. Git: Clarifying the Relationship • Git: A version

    control system that manages changes to files and coordinates work on those files among multiple people. • GitHub: A hosting service that uses Git for version control. It extends Git’s capabilities with additional features for project management. • Essentially, Git is the tool, and GitHub is a service for projects that use Git.
  19. Getting Started with GitHub • Create an Account • Creating

    and Cloning Repos • Access token • Cloning a repo git clone https://<username>:<access-token>@<repo-url> • Change directory into project that you cloned cd <project-name>
  20. Exploring Open Source Projects on GitHub • Use GitHub to

    find open-source projects. Participate by cloning projects, submitting issues, and contributing through pull requests. • Explore trending projects, contribute to ones you're interested in, and learn from the vast resources available.
  21. Pull Requests / Merge Requests • Requesting to merge your

    branch • Code Review by Lead or Manager
  22. Best Practices • Commit Messages: Writing Meaningful Commit Messages •

    Keeping Your Repositories Organized • Use SSH Keys for Authentication • Review Code for Security Flaws • Keep Dependencies Updated
  23. Why use Git and GitHub • Enhancing Collaboration and Productivity

    • Building an Online Portfolio of Your Work • Networking and Community Engagement Through Open Source • Continuous Learning and Improvement Through Real-world Projects