Git Essentials - Second Edition

Book description

Dive and explore into the latest addons of the latest Git.

About This Book

  • Master all the basic concepts of Git to protect your code and make it easier to evolve
  • Use Git proficiently, and learn how to resolve day-by-day challenges easily
  • This step-by-step guide is packed with examples to help you learn and work with Git's internals

Who This Book Is For

If you are a software developer with little or no experience of versioning systems, or you are familiar with other centralized versioning systems, then this book is for you.

If you have experience in server and system management and need to broaden your use of Git from a DevOps perspective, this book contains everything you need.

What You Will Learn

  • Master Git fundamentals
  • Be able to "visualize," even with the help of a valid GUI tool
  • Write principal commands in a shell
  • Figure out the right strategy to run change your daily work with few or no annoyances
  • Explore the tools used to migrate to Git from the Subversion versioning system without losing your development history
  • Plan new projects and repositories with ease, using online services, or local network resources

In Detail

Since its inception, Git has attracted skilled developers due to its robust, powerful, and reliable features. Its incredibly fast branching ability transformed a piece of code from a niche tool for Linux Kernel developers into a mainstream distributed versioning system. Like most powerful tools, Git can be hard to approach since it has a lot of commands, subcommands, and options that easily confuse newcomers.

The 2nd edition of this very successful book will help you overcome this fear and become adept in all the basic tasks in Git. Building upon the success of the first book, we start with a brief step-by-step installation guide; after this, you'll delve into the essentials of Git. For those of you who have bought the first edition, this time we go into internals in far greater depth, talking less about theory and using much more practical examples.

The book serves as a primer for topics to follow, such as branching and merging, creating and managing a GitHub personal repository, and fork and pull requests. You'll then learn the art of cherry-picking, taking only the commits you want, followed by Git blame. Finally, we'll see how to interoperate with a Subversion server, covering the concepts and commands needed to convert an SVN repository into a Git repository.

To conclude, this is a collection of resources, links, and appendices to satisfy even the most curious.

Style and approach

This short guide will help you understand the concepts and fundamentals of GIT is a step-by-step manner.

Publisher resources

Download Example Code

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the color images of this book 
      2. Errata
      3. Piracy
      4. Questions
  2. Getting Started with Git
    1. Foreword to the second edition
    2. Installing Git
      1. Installing Git on GNU-Linux
      2. Installing Git on macOS
      3. Installing Git on Windows
    3. Running our first Git command
      1. Making presentations
      2. Setting up a new repository
      3. Adding a file
      4. Committing the added file
      5. Modifying a committed file
    4. Summary
  3. Git Fundamentals - Working Locally
    1. Digging into Git internals
    2. Git objects
      1. Commits
        1. The hash
        2. The author and the commit creation date
        3. The commit message
        4. The committer and the committing date
        5. Going deeper
        6. Porcelain commands and plumbing commands
      2. Trees
      3. Blobs
    3. Even deeper - the Git storage object model
    4. Git doesn't use deltas
    5. Wrapping up
    6. Git references
      1. It's all about labels
      2. Branches are movable labels
      3. How references work
        1. Creating a new branch
        2. HEAD, or you are here
        3. Reachability and undoing commits
        4. Detached HEAD
        5. The reflogs
      4. Tags are fixed labels
        1. Annotated tags
    7. Staging area, working tree, and HEAD commit
      1. The three areas of Git
      2. Removing changes from the staging area
      3. File status lifecycle
      4. All you need to know about checkout and reset
        1. Git checkout overwrites all the tree areas
        2. Git reset can be hard, soft, or mixed
    8. Rebasing
      1. Reassembling commits
      2. Rebasing branches
    9. Merging branches
      1. Fast forwarding
    10. Cherry picking
    11. Summary
  4. Git Fundamentals - Working Remotely
    1. Working with remotes
      1. Clone a local repository
        1. The origin
        2. Sharing local commits with git push
        3. Getting remote commits with git pull
        4. How Git keeps track of remotes
    2. Working with a public server on GitHub
      1. Setting up a new GitHub account
      2. Cloning the repository
      3. Uploading modifications to remotes
        1. What do I send to the remote when I push?
        2. Pushing a new branch to the remote
      4. The origin
        1. Tracking branches
      5. Going backward – publishing a local repository to GitHub
        1. Adding a remote to a local repository
        2. Pushing a local branch to a remote repository
      6. Social coding - collaborating using GitHub
        1. Forking a repository
        2. Submitting pull requests
        3. Creating a pull request
    3. Summary
  5. Git Fundamentals - Niche Concepts, Configurations, and Commands
    1. Dissecting Git configuration
      1. Configuration architecture
        1. Configuration levels
          1. System level
          2. Global level
          3. Repository level
        2. Listing configurations
        3. Editing configuration files manually
        4. Setting up some other environment configurations
          1. Basic configurations
          2. Typos autocorrection
          3. Push default
          4. Defining the default editor
          5. Other configurations
    2. Git aliases
      1. Shortcuts to common commands
      2. Creating commands
        1. git unstage
        2. git undo
        3. git last
        4. git difflast
      3. Advanced aliases with external commands
      4. Removing an alias
      5. Aliasing the git command itself
    3. Useful techniques
      1. Git stash - putting changes temporally aside
      2. Git commit amend - modify the last commit
      3. Git blame - tracing changes in a file
    4. Tricks
      1. Bare repositories
        1. Converting a regular repository to a bare one
      2. Backup repositories
        1. Archiving the repository
        2. Bundling the repository
    5. Summary
  6. Obtaining the Most - Good Commits and Workflows
    1. The art of committing
      1. Building the right commit
        1. Making only one change per commit
          1. Splitting up features and tasks
          2. Writing commit messages before starting to code
        2. Including the whole change in one commit
        3. Describing the change, not what have you done
        4. Don't be afraid to commit
        5. Isolating meaningless commits
        6. The perfect commit message
          1. Writing a meaningful subject
          2. Adding bulleted details lines when needed
          3. Tying other useful information
          4. Special messages for releases
          5. Conclusions
    2. Adopting a workflow - a wise act
      1. Centralized workflows
        1. How they work
      2. Feature branch workflow
      3. Gitflow
        1. Master branch
        2. Hotfixes branches
        3. The develop branch
        4. The release branch
        5. The feature branches
        6. Conclusion
      4. GitHub flow
        1. Anything in the master branch is deployable
        2. Creating descriptive branches off of master
        3. Pushing to named branches constantly
        4. Opening a pull request at any time
        5. Merging only after pull request review
        6. Deploying immediately after review
        7. Conclusions
      5. Trunk-based development
      6. Other workflows
        1. Linux kernel workflow
    3. Summary
  7. Migrating to Git
    1. Before starting
      1. Installing a Subversion client
    2. Working on a Subversion repository using Git
      1. Creating a local Subversion repository
        1. Checking out the Subversion repository with the svn client
      2. Cloning a Subversion repository from Git
        1. Adding a tag and a branch
        2. Committing a file to Subversion using Git as a client
        3. Retrieving new commits from the Subversion server
    3. Using Git with a Subversion repository
    4. Migrating a Subversion repository
      1. Retrieving the list of Subversion users
      2. Cloning the Subversion repository
        1. Preserving ignored files
        2. Pushing to a local bare Git repository
        3. Arrange branches and tags
        4. Renaming trunk branch to master
        5. Converting Subversion tags to Git tags
        6. Pushing the local repository to a remote
    5. Comparing Git and Subversion commands
    6. Summary
  8. Git Resources
    1. Git GUI clients
      1. Windows
        1. Git GUI
        2. TortoiseGit
        3. GitHub for Windows
        4. Atlassian SourceTree
        5. Cmder
      2. macOS
      3. Linux
    2. Building up a personal Git server with web interface
      1. SCM Manager
    3. Learning Git in a visual manner
    4. Git on the internet
      1. Git for human beings Google Group
      2. Git community on Google+
      3. Git cheat sheets
      4. Git Minutes and Thomas Ferris Nicolaisen blog
      5. Online videos
      6. Ferdinando Santacroce's blog
    5. Summary

Product information

  • Title: Git Essentials - Second Edition
  • Author(s): Ferdinando Santacroce
  • Release date: November 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781787120723