Head First Git: A Learner's Guide to Understanding Git from the Inside Out

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

What will you learn from this book? Many people who use Git rely on "recipes"--copying and pasting commands they find on the internet without really understanding how Git 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 the ways of Git and have fun while doing it. Raju Gandhi peels back the layers to reveal the simple yet powerful engine that powers Git, so you'll understand not just the how but the why. You'll master branches, merges, commit messages, search, utilities, and more; learn best practices for collaborative work; 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.

Author(s): Raju Gandhi
Edition: 1
Publisher: O'Reilly Media
Year: 2022

Language: English
Commentary: Vector PDF
Pages: 506
City: Sebastopol, CA
Tags: Git; Version Control Systems; Elementary; Developer Tools

Author of Head First Git
Table of Contents
Intro: how to use this book
Who is this book for?
We know what you’re thinking
We know what your brain is thinking
Metacognition: thinking about thinking
Here’s what WE did
Here’s what YOU can do to bend your brain into submission
Read me
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
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 anymore acknowledgments*
Chapter 1: beginning Git (Get Going with Git)
Why we need version control
Cubicle Conversation
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 ls
More on the command line (almost there):changing directories with cd
No argument there
Cleaning up
Creating your first repository
Inside the init command
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...
What exactly does it mean to commit?
What exactly does it mean to commit? (continued)
Look before you leap
The three stages of Git
Git in the command line
A peek behind the curtain
The multiple states of files in a Git repository
The index is a “scratch pad”
Computer, status report!
You’ve made history!
Chapter 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
Choices...so many choices!
Switching tracks
Back at the ’80s Diner
Send it back!
Visualizing branches
Branches, commits, and the files contained within
Cubicle Conversation
Working in parallel
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 straightforward
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! (continued)
I am so conflicted! (Ooof! Almost there)
Cleaning up (merged) branches
Deleting unmerged branches
A typical workflow
Chapter 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 staged changes (continued)
Diffing branches
Diffing branches (continued)
Diffing branches (we are there!)
Diffing commits
What does the diff for a new file look like?
Chapter 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
Undoing changes to the index (continued)
Deleting files from Git repositories
Committing to delete
Renaming (or moving) files
Editing commit messages
Editing commit messages (continued)
Renaming branches
Making alternative plans
The role of HEAD
Referencing commits using HEAD
Traversing merge commits
Undoing commits
Removing commits with reset
The three types of reset
Another way to undo commits
Reverting commits
Aaaaand that’s a wrap!
Chapter 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!
Ready, set, clone! (continued)
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
Pushing local branches (continued)
Merging branches: option 2 (pull requests)
Creating pull requests
Creating pull requests (continued)
Creating pull requests (Yep! Almost there)
A brand-new, shiny pull request
Pull requests or merge requests?
Merging a pull request
What’s next?
Chapter 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
The setup for two collaborators on GitHub (continued)
Our setup so far
Cubicle conversation (continued)
Falling behind the remote
Cubicle conversation (continued)
Catching up with the remote (git pull)
Catching up with the remote (git pull, continued)
Introducing the middlemen, aka remote tracking branches
Reason 1 for remote tracking branches: knowing where to push
Reason 1 for remote tracking branches:knowing where to push (continued)
Pushing to the remote: summary
Fetching remote tracking branches
Reason 2 for remote tracking branches:getting (all) updates from the remote
Cubicle conversation (continued)
Collaborating with others
Collaborating with others (continued)
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 (continued)
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
Cleaning up remote branches (continued)
Chapter 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
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 (continued)
Using the “patch” flag with git log (almost there)
git log's other “pickaxe” flag (-G)
Searching commit messages
What does it mean to check out a commit?
Checking out commits
Detached HEAD state
The moral of the detached HEAD story state
Cubicle conversation
Searching for commits using git bisect
Using git bisect
Using git bisect (continued)
Finishing git bisect
Chapter 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
The anatomy of a good commit message: bodies
Fussy much?
Create helpful branch names
Integrate a graphical user interface into your workflow
appendix: leftovers (The Top Five Topics We Didn’t Cover)
#1 Tags (remember me forever)
#2 Cherry-pick (copying commits)
#3 Stashes (pseudo-commits)
#3 Stashes (pseudo-commits, continued)
#4 reflog (reference log)
#5 rebase (another way to merge)
#5 rebase (another way to merge, continued)
Index