
Head First Git: A Learner’s Guide to Understanding Git from the Inside Out
- Length: 650 pages
- Edition: 1
- Language: English
- Publisher: O'Reilly Media
- Publication Date: 2022-01-04
- ISBN-10: 1492092517
- ISBN-13: 9781492092513
- Sales Rank: #5318659 (See Top 100 Books)
What will you learn from this book?
Many people who use Git rely on “recipes”–basic copy-paste commands–without understanding how this version control system actually works. But what do you do if you find yourself in a tight spot? You can’t simply wing it. With this unique hands-on guide, you’ll learn valuable ways to use Git in many different situations. Raju Gandhi peels back the layers to reveal the simple yet powerful engine that powers Git, with activities that help you truly understand this crucial tool as you get it up and running. You’ll master branches, tags, stashes, and merges; learn best practices; collaborate with your team; and unlock the full potential of Git.
What’s so special about this book?
If you’ve read a Head First book, you know what to expect–a visually rich format designed for the way your brain works. If you haven’t, you’re in for a treat. With this book, you’ll learn Git through a multisensory experience that engages your mind rather than a text-heavy approach that puts you to sleep.
Other books in O’Reilly’s Head First series Author of Head First Git Table of Contents (the real thing) How to use this Book: Intro Who is this book for? Who should probably back away from this book? We know what you’re thinking We know what your brain is thinking This must be important! Don’t forget it! Metacognition: thinking about thinking So just how DO you get your brain to treat Git like it’s a hungry tiger? Here’s what WE did Here’s what YOU can do to bend your brain into submission Read me We break things down, then build them back again. We don’t exhaustively cover everything. The activities are NOT optional. The redundancy is intentional and important. The examples are as generic as possible. The Brain Power exercises don’t have answers. Not all Test Drive exercises have answers. You’re going to have to install Git (macOS) Using the terminal to verify the installation You’re going to have to install Git (Windows) Using Git Bash to verify the installation You’re going to need a text editor (macOS) You’re going to need a text editor (Windows) You’re (definitely) going to need a GitHub account Setting up a personal access token A word on organizing your files and projects The technical review team O’Reilly Online Learning Acknowledgments Just when you thought there wouldn’t be any more acknowledgments* 1. Beginning Git: Get Going with Git Why we need version control Cubicle Conversation Got Git? Start your engines... A quick tour of the command line: knowing where you are with pwd More on the command line: creating new directories with mkdir (Even) More on the command line: listing files with Is More on the command line (almost there): changing directories with cd No argument there Cleaning up Creating your first repository Inside the init command Code Magnets Introduce yourself to Git How you will use Git Putting Git to work Meanwhile, back at the HawtDog Dating Service... Working with the HawtDawg Git repository Speaking of... Congratulations on your first commit! What exactly does it mean to commit? Look before you leap The three stages of Git Great question! Git in the command line A peek behind the curtain The multiple states of files in a Git repository A typical day in the life of a new file The object database is the “source of truth” BE Git The index is a “scratch pad” Computer, status report! Whoa, easy tiger! You’ve made history! Crossword Init Code Magnets Solution BE Git Solution Crossword Init Solution 2. Branching Out: Multiple Trains of Thought It all started with an email But things didn’t quite pan out... What would you do if you were Norm? Updating the restaurant menu First things first Very astute! Choices...so many choices! Switching tracks Back at the ’80s Diner Send it back! Code Magnets Visualizing branches Branches, commits, and the files contained within BE Git Cubicle Conversation Working in parallel BE Git What is a branch, really? Switching branches, or switching directories? Some branches are more equal than others Bring it in! Read the #&$!@ manual (git branch edition) Making the fall menu official Some merges are fast-forward It doesn’t quite work the other way A little more Git setup It’s almost Thursday! Wait! You moved? It’s almost Thursday! (continued) It’s a merge commit Merge commits are kinda special Things don’t always go so smoothly I am so conflicted! I am so conflicted! (Ooof! Almost there) Cleaning up (merged) branches The answer to your question lies in the commit history. Deleting unmerged branches A typical workflow Git branch “crossword puzzle” Code Magnets Solution BE Git Solution BE Git Solution Git branch “crossword puzzle” Solution 3. Looking Around: Investigating Your Git Repository Brigitte’s on a mission Commits aren’t enough Mirror, mirror on the wall: who is the prettiest log of all? How does git log work? Making git log do all the work What diff-erence does it make? Visualizing file differences Visualizing file differences: one file at a time Visualizing file differences: one hunk at a time Making diffs easier on the eyes Diffing staged changes Diffing branches Diffing branches (we are there!) Diffing commits What does the diff for a new file look like? A Diff-icult Crossword A Diff-icult Crossword Solution 4. Undoing: Fixing Your Mistakes Planning an engagement party An error in judgment Cubicle conversation Undoing changes to the working directory Undoing changes in the index Deleting files from Git repositories Committing to delete Renaming (or moving) files Editing commit messages Aren’t you the observant one! Renaming branches Making alternative plans HEAD Tells All The role of HEAD Referencing commits using HEAD Traversing merge commits Undoing commits Removing commits with reset The three types of reset git reset --soft Using git reset (or git reset --mixed) git reset --hard Congratulations, you time traveler, you! Another way to undo commits Reverting commits Aaaaand that’s a wrap! Undo Crossword Undo Crossword Solution 5. Collaborating with Git - Part I: Remote Work Another way to a Git repository: cloning Hosting a Git repository Setting up: forking repositories (a sidebar) Ready, set, clone! It’s just another Git repository What happens when you clone? Git is distributed Another bit of Git configuration Pushing changes Verifying if the push worked Knowing where to push: remotes No photographs, please: public versus private commits Public versus private commits (continued) Standard operating procedure: branches Merging branches: option 1 (local merges) A quick note on GitHub’s interface Pushing local branches Merging branches: option 2 (pull requests) Creating pull requests Creating pull requests (Yep! Almost there) A brand-new, shiny pull request Pull requests or merge requests? Merging a pull request What’s next? A Pushy Puzzle A Pushy Puzzle Solution 6. Collaborating with Git - Part II: Go, Team, Go! Cubicle conversation Working in parallel Working in parallel...in Gitland Cubicle conversation (continued) Collaborating, Git style The setup for two collaborators on GitHub Our setup so far Two-player setup One-player setup Cubicle conversation (continued) Falling behind the remote Cubicle conversation (continued) Catching up with the remote (git pull) Introducing the middlemen, aka remote tracking branches Reason 1 for remote tracking branches: knowing where to push Remote tracking branch after you push Pushing to the remote: summary Fetching remote tracking branches Reason 2 for remote tracking branches: getting (all) updates from the remote Git branch flag soup Cubicle conversation (continued) Collaborating with others Git push/pull and remote tracking branches Collaborating with others: summary Reason 3 for remote tracking branches: knowing you need to push Reason 4 for remote tracking branches: getting ready to push Reason 4 (still going) Reason 4 (Yep! Almost there!) git pull is git fetch + git merge! Use git fetch + git merge. Avoid git pull. The ideal scenario A typical workflow: getting started A typical workflow: getting ready to merge A typical workflow: merge locally, or issue pull requests? A typical workflow visualized Cleaning up remote branches Collaborative Crossword Collaborative Crossword Solution 7. Searching Git Repositories: Git a Grep Taking things to the next level A walk through the commit history Cubicle conversation Seeing who changed what and when with git blame Using git blame git blame using Git repository managers A few more details about git blame Searching Git repositories Searching Git repositories with grep git grep options Case-insensitive search Displaying line numbers List only filenames The git grep flags combo Where git blame falls short git log’s “pickaxe” capability (-S) git log -S versus blame Using the “patch” flag with git log Using the “patch” flag with git log (almost there) git log’s other “pickaxe” flag (-G) Searching commit messages Git log flag soup What does it mean to check out a commit? Checking out commits Detached HEAD state The moral of the detached HEAD state Cubicle conversation Searching for commits using git bisect Using git bisect Finishing git bisect Searching for Clues Searching for Clues Solution 8. Making your life Easier with Git: #ProTips Configuring Git The global .gitconfig file Project-specific Git configuration Listing your Git configuration Git aliases, aka your personal Git shortcuts Tweaking the behavior of Git aliases Telling Git to ignore certain files and folders The effects of a .gitignore file Managing the .gitignore file A sample .gitignore file Commit early, commit often Write meaningful commit messages The anatomy of a good commit message The anatomy of a good commit message: headers Code Magnets The anatomy of a good commit message: bodies Fussy much? A shoutout Create helpful branch names Integrate a graphical user interface into your workflow The command line versus a GUI Congratulations! Configuration Crossword Code Magnet Solution Configuration Crossword Solution A. Leftovers: The Top Five Topics We Didn’t Cover #1 Tags (remember me forever) #2 Cherry-pick (copying commits) #3 Stashes (pseudo-commits) #4 reflog (reference log) #5 rebase (another way to merge) This isn’t goodbye! Index
How to download source code?
1. Go to: https://www.oreilly.com/
2. Search the book title: Head First Git: A Learner’s Guide to Understanding Git from the Inside Out
, sometime you may not get the results, please search the main title
3. Click the book title in the search results
3. Publisher resources
section, click Download Example Code
.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.