0%

Learn to track, branch, merge, and manage code revisions for real-world development scenarios

Key Features

  • Master Git and understand the significance of version control
  • Get to grips with Git's typical workflows, advanced functions, and their implementations
  • Understand important Git commands to manage your repository

Book Description

Git is the most popular version control system in the world. It allows developers to keep up with frequent code changes in a project, ensures there are no code conflicts between the developers, and reverts to an older version of code when required.

Git for Programmers comprehensively equips you with actionable insights on advanced Git concepts in an engaging and straightforward way. This book will help you gain expertise on Git with many practical use cases as you progress through the chapters.

The book begins with a quick history of Git and instructions on how to get it and install it, after which you'll dive into the creation and cloning of your repository. As you progress through the book, you'll explore Git places, branching, and GUIs.

Once you understand the fundamentals, you'll learn how to handle merge conflicts, rebase, amend, interactive rebase, and use the log. You'll also explore important Git commands for managing your repository. Finally, the book concludes with coverage of bisect, blame, and several other problem handling techniques.

By the end of this book, you'll be able to use Git with confidence; saving, sharing, and managing files as well as undoing mistakes and rewriting history.

What you will learn

  • Create and clone repositories
  • Understand the difference between local and remote repositories
  • Use, manage, and merge branches back into the main branch
  • Utilize tools to manage merge conflicts
  • Manage commits on your local machine through interactive rebasing
  • Use the log to gain control over all the data in your repository
  • Use bisect, blame, and other tools to undo Git mistakes

Who this book is for

If you have basic understanding of Git and want to strengthen your command over advanced techniques and navigate different functions, this book is for you.

Table of Contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the color images
    5. Conventions used
    6. Get in touch
    7. Share your thoughts
  2. Introduction
    1. About this book
    2. Version control
    3. About the code examples
    4. Just a brief history
    5. Tools for working with Git
    6. GitHub, et al.
    7. GUIs and the command line
    8. The command line
    9. Making the command line pretty
    10. Visual Studio 2019
    11. Getting Visual Studio for free
    12. GitHub Desktop
    13. Getting Git
    14. Getting Git on Windows
    15. Getting Git on a Mac
    16. Getting Git on Linux
    17. Checking your version
    18. Configuring Git – the command line
    19. Configuring Git – Visual Studio
    20. Configuring Git – GitHub Desktop
    21. Summary
  3. Creating Your Repository
    1. Creating your repository
    2. Creating your repository on GitHub first
    3. Cloning to your computer – command line
    4. Cloning to your computer – visual studio
    5. Cloning to your computer – GitHub for Desktop
    6. Creating a project
    7. Git pull
    8. Pulling down using GitHub Desktop
    9. Pulling down to Visual Studio
    10. Push me, pull you
    11. Pushing to the server
    12. Downloading the changes at the command line
    13. Downloading the changes using GitHub Desktop
    14. Starting at the command line
    15. Pulling to GitHub Desktop
    16. Pulling to Visual Studio
    17. Commits – best practices
    18. How often should I commit?
    19. Keep your commit history clean
    20. A note on commit messages
    21. When the title isn't enough
    22. Summary
  4. Branching, Places, and GUIs
    1. Five places
    2. The work area
    3. The index/staging area
    4. Skipping the staging area
    5. Visual Studio
    6. GitHub Desktop
    7. Local and remote repositories
    8. The stash
    9. Branches
    10. Programmer 1 (CommandLine) and calculator
    11. Pushing the new branch
    12. Examining origin
    13. Adding commits to a branch
    14. The Book branch – Git within Visual Studio
    15. Committing with GitHub Desktop
    16. Status
    17. What's on origin?
    18. Adding more commits
    19. Examining your commits
    20. Summary
    21. Challenge
    22. Answer
  5. Merging, Pull Requests, and Handling Merge Conflicts
    1. Merging overview
    2. Book
    3. What's in that push?
    4. Visual Studio
    5. Details, details
    6. GitHub Desktop
    7. Push it already
    8. Visual Studio
    9. Merge conflicts
    10. Merging from the command line
    11. Fast forward
    12. True merge
    13. Avoiding conflicts
    14. Summary
    15. Challenge
    16. Answer
    17. Task #1: Set up a new repository and clone it to two different folders
    18. Task #2: Have one person populate the main branch with the beginnings of UtilityKnife, commit the changes, and push it
    19. Task #3: Each programmer creates a feature branch. Each programmer then puts the beginning of their feature into their branch, committing frequently (more frequently than you would in "real life")
    20. Sara and the Calculator
    21. Task #4: Merge the main branch into the feature branch frequently to ensure that if there are conflicts, you catch them early
    22. Task #5: John is building the temperature converter. Have him "borrow" code from the calculator. See if there are merge conflicts
  6. Rebasing, Amend, and Cherry-Picking
    1. Rebasing
    2. How Git does it
    3. Getting your head around it
    4. Rebase early and rebase often
    5. Rebase locally only
    6. Rebasing in practice
    7. Seeing the rebase at work
    8. Conflicts
    9. Amending
    10. Cherry-picking
    11. Visual Studio cherry-picking
    12. Summary
    13. Challenge
    14. Answer
    15. Creating a new repository on GitHub
    16. Creating two feature branches with fake programmers
    17. Frequent rebasing
    18. Amending a commit to add a file
    19. Amending a commit to change the message
    20. Cherry-picking one commit onto main
  7. Interactive Rebasing
    1. Interactive rebasing at work
    2. Creating our example
    3. Using interactive rebase to clean up your commits
    4. Summary
    5. Challenge
  8. Workflow, Notes, and Tags
    1. Standard workflow
    2. Mirroring your repo
    3. Replicating an existing repo
    4. Adding and showing notes
    5. Tags
    6. Pointing to a different tag
    7. Summary
    8. Challenge
  9. Aliases
    1. Aliases
    2. Summary
    3. Challenge
    4. Answer
  10. Using the Log
    1. Getting started with log
    2. The LogDemo program
    3. Visual Studio
    4. GitHub Desktop
    5. log at the command line
    6. Which files changed?
    7. What changed in each file?
    8. diff
    9. Visual Studio
    10. What changed in this file over time?
    11. Search
    12. Where are my commits?
    13. Summary
    14. Challenge
    15. Answer
    16. Create a new repository
    17. Add at least 6 commits
    18. Find the names of every file changed in each commit
    19. Find what changed in a given file over time
    20. Find all the files you committed in the past hour (or whatever time increment makes sense)
  11. Important Git Commands and Metadata
    1. Stash
    2. Clean
    3. Metadata
    4. Summary
    5. Challenge
    6. Answer
  12. Finding a Broken Commit: Bisect and Blame
    1. Blame
    2. Challenge
  13. Fixing Mistakes
    1. You wrote the wrong message in the last commit
    2. You forgot to add changed files from your last commit
    3. Problems with the order of commits or their messages
    4. You need to undo changes made in a commit
    5. You misnamed your branch
    6. You committed to the wrong branch
    7. You trashed a file in a previous commit
    8. You messed up the remote by pushing a broken branch
    9. Quiz
    10. Answers
    11. What do you do if you left out a changed file in the last commit?
    12. What do you do if you committed to the wrong branch?
    13. What do you do if you corrupted a file in a previous commit?
    14. What do you do if you need to undo changes made in a commit?
    15. What do you do if you trashed Master by pushing a broken branch?
  14. Next Steps
  15. Other Books You May Enjoy
  16. Index
18.226.93.207