O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Version Control with Git and GitHub

Book Description

Learn to create and enforce checks and controls for tracking, merging, and approval of changes in your source code

Key Features

  • Explore version control, its importance, and usage
  • Learn to use Git individually and as part of a team
  • Understand debugging, maintenance, and deployment with Git and GitHub

Book Description

Introduction to Git and GitHub begins with setting up and configuring Git on your computer along with creating a repository and using it for exercises throughout the book. With the help of multiple activities, you'll learn concepts that show various stages of a file—from when it is untracked to when it is set for tracking under version control. As you make your way through the chapters, you'll learn to navigate through the history of a repository, fetch and deliver code to GitHub, and undo code changes.

The first half of the book ends with you learning to work with branches, storing and retrieving changes temporarily, and merging the desired changes into a repository.

In the second half, you'll learn about forking as part of a collaborative workflow. You'll also address modularity and duplication through submodules, tracing and rectifying faulty changes, and maintaining repositories.

By the end of this book, you will have learned how to effectively deploy applications using GitHub.

What you will learn

  • Understand and implement best practices in version control
  • Explain the GitHub User Interface
  • Understand what is Feature Branch Workflow and implement its features
  • Use forking features, such as submodules and rebasing
  • Master commands for debugging and maintaining a repository
  • Implement continuous integration with CircleCi or TravisCi
  • Gain insight into release management and how GitHub enables software releases

Who this book is for

If you want to migrate from other version control tools or want to learn more about Git, Introduction to Git and GitHub is for you. Prior experience in coding or familiarity with using the Bash command line interface will help you easily grasp concepts.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Preface
    1. About the Book
      1. About the Authors
      2. Objectives
      3. Audience
      4. Approach
      5. Minimum Hardware Requirements
      6. Software Requirements
      7. Installing the Code Bundle
      8. Additional Resources
      9. Conventions
      10. Installing Atom IDE
      11. Installing Git
  2. Introducing Version Control
    1. Introduction
    2. Defining Version Control
      1. Applications of Version Control
      2. Common Terminologies
      3. Feature branch workflow
      4. Forking Workflow
    3. Navigating GitHub
      1. Exercise 1: Setting Up a GitHub Account
      2. Exercise 2: Utilizing Two-Factor Authentication
      3. Organizations
      4. Exercise 3: Setting Up an Organization
      5. Exercise 4: Setting Up a Team
      6. Marketplace
      7. Exercise 5: Setting Up Codacy for Accounts
      8. Runtime Config
      9. Exercise 6: Setting User Credentials
      10. Removing Configuration
      11. SSH Configuration
      12. Exercise 7: Setting Up SSH
      13. Creating a Repository
      14. Exercise 8: Creating a Repository in a Local Environment
      15. Exercise 9: Creating a Repository on GitHub
      16. Navigating a Repository
      17. Collaborators
      18. Exercise 10: Adding and Deleting Contributors
      19. Navigating Branches, Commits, and Insights (Contributors, Pulse, Forks)
      20. GitHub Etiquette
      21. Repository Names, Tags, and Descriptions
      22. Exercise 11: Adding Licenses
      23. Wikis and Issues
      24. Activity 1: Creating a Repository
    4. Summary
  3. Versioning Commits
    1. Introduction
    2. Introduction to Versioning Commits
      1. Exercise 12: Viewing and Establishing the Status of a File
      2. Comparing the Working Tree to the Index
      3. Comparing the Working Tree to an Arbitrary Commit or Branch
      4. Comparing the Index to an Arbitrary Commit
      5. Comparing Commits and Branches
      6. Exercise 13: Examining Differences Between Files
      7. Exercise 14: Adding Files to the Index
      8. Exercise 15: Removing Files from the Working Tree and the Index
      9. Exercise 16: Moving and Renaming Files
      10. History and Logs
      11. Amending Commits
      12. Amending a Single Most Recent Commit
      13. Exercise 17: Editing the Most Recent Commit
      14. Amending Multiple Commits
      15. Exercise 18: Editing Commits Using the reword Command
      16. Exercise 19: Editing Commits Using the edit Command
      17. Activity 2: Tracking Files
    3. Summary
  4. Fetching and Delivering Code
    1. Introduction
    2. Fetching the Code
      1. Exercise 20: Configuring the Remote Repository
      2. Default and Protected Branches
      3. Exercise 21: Configuring the Base Branch and Branch Protection
      4. Fetching, Pushing, and Pulling Changes
      5. Exercise 22: Retrieving Changes
      6. Dealing with Non-Fast-Forward Commits
      7. Reversing Commits
      8. Exercise 23: Reversing Changes
      9. Other Possible Uses
      10. Activity 3: Handling Changes and Enforcing Branch Restrictions
    3. Summary
  5. Branches
    1. Introduction
    2. Utilizing Workflows
      1. Creating a Centralized Workflow
      2. Feature Branch Workflow
      3. Forking Workflow
      4. Feature-Branch Workflow
      5. Exercise 24: Feature-Branch Workflow-Driven Delivery
      6. Creating, Renaming, Deleting, and Listing Branches
      7. Creating:
      8. Merging
      9. Cherry-Pick
      10. Pull Request (PR)
      11. Exercise 25: Examining Branch Differences
      12. Pull Request Templates
      13. Exercise 26: Standardizing Procedures through Ordered Templates
      14. Identifying and Fixing Merge Issues
      15. Exercise 27: Merge Conflict Resolution
      16. Exercise 28: Resolving Conflicts
      17. Merging and Reverting Pull Requests
      18. Exercise 29: Pull Request Reversal
      19. Activity 4: Managing Branches and Experimentation with Selective Changes
    3. Summary
  6. Collaborative Git
    1. Introduction
    2. Forking the Workflow
      1. Exercise 30: Forking a Repository
      2. Why Do We Fork Repositories?
      3. Embedding Upstream Changes
      4. Exercise 31: Modifying the Upstream Repository Remote Address
      5. Rebasing
      6. Exercise 32: Rebasing in GitHub
      7. Fixup and Squash Commits
      8. Exercise 33: Utilizing the Autosquash Feature
      9. Drop Commits
      10. Exercise 34: Dropping Commits
      11. Submodules
      12. Exercise 35: Utilizing Gitmodules
      13. Activity 5: Rebasing
    3. Debugging and Maintenance
      1. Exercise 36: Identifying Revisions Using Git Blame
      2. Exercise 37: Finding Commits using Git Bisect
    4. Housekeeping
      1. Exercise 38: Removing Untracked Files using Git Clean
      2. Removing Merged Local and Remote Branches
      3. Exercise 39: Deleting Branches
      4. Activity 6: Utilizing Pre-Commit Hooks for Housekeeping
    5. Summary
  7. Automated Testing and Release Management
    1. Introduction
    2. Test Automation
      1. Webhooks and GitHub Applications
      2. Exercise 40: Setting up a Webhook
      3. GitHub Applications
      4. Exercise 41: Setting Up CircleCi CI
    3. Automated Pull Requests
      1. Exercise 42: Utilizing Automated Pull Requests
      2. Activity 7: Integrating a Build Pipeline on CircleCi
    4. Release Management
      1. Tagging
      2. Exercise 43: Creating Tags
      3. Exercise 44: Publishing GitHub Releases
    5. Git Archive
      1. Exercise 45: Packaging through GitHub Archive
      2. Activity 8: Tagging and Releasing with Git
    6. Summary
  8. Appendix
    1. Chapter 1: Introducing Version Control
      1. Activity 1: Repository Creation
      2. Chapter 2: Versioning Commits
      3. Activity 2: Tracking Files
      4. Chapter 3: Fetching and Delivering Code
      5. Activity 3: Handling Changes and Enforcing Branch Restrictions
      6. Chapter 4: Branches
      7. Activity 4: Managing Branches and Experimentation with Selective Changes
      8. Chapter 5: Collaborative Git
      9. Activity 5: Rebasing
      10. Activity 6: Utilizing Pre-Commit Hooks for Housekeeping
      11. Chapter 6: Automated Testing and Release Management
      12. Activity 7: Integrating a Build Pipeline on CircleCi
      13. Activity 8: Tagging and Releasing with Git