Book description
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.
Table of contents
- 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?
- 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
- 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
- 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
- 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...
- What exactly does it mean to commit?
- 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!
-
2. Branching Out: Multiple Trains of Thought
- It all started with an email
- 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 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
- Deleting unmerged branches
- A typical workflow
-
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?
-
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
- 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
- Congratulations, you time traveler, you!
- Another way to undo commits
- Reverting commits
- Aaaaand thatâs a wrap!
-
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?
-
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
- 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
- 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
- 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
-
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 (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
-
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
- A. Leftovers: The Top Five Topics We Didnât Cover
- Index
Product information
- Title: Head First Git
- Author(s):
- Release date: January 2022
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781492092513
You might also like
book
Modern Software Engineering: Doing What Works to Build Better Software Faster
Improve Your Creativity, Effectiveness, and Ultimately, Your Code In Modern Software Engineering, continuous delivery pioneer David …
book
Tidy First?
Messy code is a nuisance. "Tidying" code, to make it more readable, requires breaking it up …
book
Learning Git
This book teaches Git in a simple, visual, and tangible manner so that you can build …
book
Learning TypeScript
TypeScript has conquered the world of JavaScript: it's one of the world's fastest growing and most …