Learn Git in a Month of Lunches
Rick Umali
  • September 2015
  • ISBN 9781617292415
  • 376 pages
  • printed in black & white

A must-read resource ... learn how to use Git for maximum day-to-day effectiveness.

Scott M. King, Amazon

Learn Git in a Month of Lunches introduces the discipline of source code control using Git. Whether you're a newbie or a busy pro moving your source control to Git, you'll appreciate how this book concentrates on the components of Git you'll use every day. In easy-to-follow lessons designed to take an hour or less, you'll dig into Git's distributed collaboration model, along with core concepts like committing, branching, and merging.

Table of Contents detailed table of contents

preface

about this book

author online

about the authors

acknowledgments

1. Before you begin

1.1. What makes Git so special?

1.2. Is this book for you?

1.3. How to use this book

1.4. Installing Git

1.5. Your learning path

1.6. Online resources

1.7. Being immediately effective

2. An Overview of Git and Version Control

2.1. Version control concepts

2.1.1. Version control for the software developer

2.1.2. Version control for the organization

2.1.3. What is a repository?

2.1.4. What is a commit?

2.1.5. What is a branch?

2.2. Git’s key features

2.2.1. Distributed repositories

2.2.2. Fast branching

2.2.3. The staging area

2.3. A quick tour of Git

2.3.1. Using the GUI to tour a Git repository

2.3.2. Using the command line to tour a Git repository

2.4. Version control terminology

3. Getting Oriented with Git

3.1. Getting set up

3.1.1. Git command-line syntax

3.1.2. Common commands

3.2. Using commands

3.3. Improving command-line efficiency

3.4. Using Git help

3.5. Controlling long output with a pager

3.6. Lab

3.7. Further Exploration

3.8. Commands in this chapter

4. Making and Using a Git Repository

4.1. Understanding repository basics

4.2. Creating a new repository with git init

4.3. Tracking files with git status and git add

4.3.1. Using git status to check your repository state

4.3.2. Using git add to add a file to your repository

4.4. Committing files with git commit

4.5. Viewing the repository with git log and ls-files

4.6. Lab

4.7. Commands in this chapter

5. Using Git with a GUI

5.1. Starting Git GUI

5.1.1. Starting Git GUI in Windows

5.2. Creating a repository with Git GUI

5.3. Adding a file into the repository via Git GUI

5.4. Looking at your history

5.5. Lab

5.6. Further exploration

5.6.1. Other GUIs for Git

5.6.2. Tcl, Tk, and Wish

5.7. Commands in this chapter

6. Tracking and Updating Files in Git

6.1. Making simple changes

6.1.1. Creating a new repository

6.1.2. Telling Git about changes

6.1.3. Seeing what’s different

6.1.4. Adding and committing changes to the repo

6.2. Thinking about git add

6.2.1. An analogy to introduce the staging area

6.2.2. Adding changes to the staging area

6.2.3. Updating the staging area

6.2.4. Understanding the staging area

6.2.5. Committing changes

6.3. Adding multiple files

6.4. Lab

6.4.1. Understanding command-line nuances

6.4.2. Getting out of trouble

6.4.3. Adding your own file

6.5. Further exploration

6.6. Commands in this chapter

7. Committing Parts of Changes

7.1. Deleting files from Git

7.2. Renaming files in Git

7.3. Adding directories into your repository

7.3.1. Reconsidering the stage analogy

7.3.2. Considering when to commit

7.3.3. Committing parts of a file by using Git GUI

7.3.4. Committing parts of a file using git add -p

7.3.5. Removing changes from the staging area

7.3.6. Resetting a file to the last committed version

7.3.7. Understanding consequences of partial commits

7.4. Adding parts of changes

7.5. Lab

7.5.1. Working with multiple hunks

7.5.2. Changing your mind with a delete

7.5.3. Reading assignments

7.6. Commands in this chapter

8. The Time Machine that is Git

8.1. Working with git log

8.1.1. Working with the SHA1 ID

8.1.2. Exploring meta information

8.1.3. Using gitk to view the commit history

8.1.4. Finding all commits by file

8.1.5. Using variations of git log

8.2. Making proper commit log messages

8.3. Checking out a specific version

8.3.1. Understanding HEAD, master, and other names

8.3.2. Going back in time with git checkout

8.4. Breadcrumbs to previous versions

8.5. Lab

8.5.1. Viewing history (part 1)

8.5.2. Amending commits

8.5.3. Using other names

8.5.4. Committing while in detached HEAD mode

8.5.5. Deleting tags

8.5.6. Viewing history (part 2)

8.6. Further exploration

8.7. Commands in this chapter

9. Taking a fork in the road

9.1. Introducing branches

9.1.1. Creating references

9.1.2. Understanding that master is just a convention

9.2. When and how to create branches

9.2.1. Introducing new code with branches

9.2.2. Introducing fixes with branches

9.3. Performing other branch operations

9.3.1. Branching faster

9.3.2. Deleting branches

9.4. Switching branches safely

9.4.1. Stashing away your work

9.4.2. Popping the stash

9.5. Lab

9.5.1. Using the GUI for branch work

9.5.2. Warm-up questions

9.5.3. Working on another_fix_branch

9.5.4. Viewing branches

9.6. Further exploration

9.7. Commands in this chapter

10. Merging branches

10.1. Considering point of view: traffic merges into us

10.2. Performing a merge

10.2.1. Starting with at least two branches

10.2.2. Checking the difference between two branches

10.2.3. Performing the merge

10.2.4. Working with a merge commit’s parents

10.2.5. Performing merges in Git GUI

10.3. Handling merge conflicts

10.3.1. Understanding differences that Git can’t handle

10.3.2. Merging files by directly editing conflicting hunks

10.3.3. Merging files by using a merge tool

10.3.4. Aborting a merge

10.4. Performing fast-forward merges

10.4.1. Understanding the direct-descendant concept

10.4.2. Making a fast-forward merge

10.5. Lab

10.6. Further exploration

10.6.1. Calculating the base of a merge with git merge-base

10.6.2. Changing how conflicts are displayed (merge.conflictstyle)

10.6.3. Performing octopus merges

10.7. Commands in this chapter

11. Cloning

11.1. Cloning: making copies locally

11.1.1. Using git clone

11.1.2. Viewing branches in your clone

11.1.3. Checking out branches

11.2. Working with the bare directory

11.2.1. Examining Git repository files

11.2.2. Creating bare directories with git clone

11.2.3. Cloning from bare directories

11.3. Listing files in the repo by using git ls-tree

11.4. Lab

11.5. Further exploration

11.6. Commands in this chapter

12. Collaborating with Remotes

12.1. Remotes are distant places

12.1.1. Analyzing a clone’s origin (git remote)

12.1.2. Renaming a remote

12.1.3. Adding a remote

12.2. Interrogating a remote

12.3. Getting a clone from somewhere remote

12.4. Lab

12.4.1. Exploring your math.github clone

12.4.2. Making remotes manually

12.4.3. Using other git remote subcommands

12.4.4. Creatin clones with Git GUI

12.4.5. Accessing another remote URL

12.5. Further exploration

12.6. Commands in this chapter

13. Pushing Your Changes

13.1. Pushing sends changes to a remote

13.1.1. Permissions are required

13.1.2. Pushing requires a branch and a remote

13.1.3. Verifying a successful git push

13.2. Understanding push conflicts

13.3. Pushing branches

13.4. Deleting branches on the remote

13.5. Pushing and deleting tags

13.6. Configuring simple pushes

13.7. Lab

13.8. Further exploration

13.9. Commands in this chapter

14. Keeping in Sync

14.1. Completing the cycle of collaboration

14.2. Using git pull: a two-part operation

14.2.1. Fetching files from a remote repository (git fetch)

14.2.2. Merging two branches (git merge)

14.3. Merging a pull

14.3.1. Clean merge

14.3.2. Clean merge with nonautomatic commit

14.3.3. Clean merge with automatic commit

14.3.4. Conflicted merges

14.4. Restricting pulls to fast-forwards only

14.5. Using git fetch and merge instead of pull

14.6. Lab

14.7. Commands in this chapter

15. Software Archaeology

15.1. Understanding git log

15.1.1. Reviewing the basics of git log

15.1.2. Limiting the display of commits

15.1.3. Seeing differences with git log

15.1.4. Using git name-rev to name commits

15.2. Understanding gitk view configurations

15.2.1. Showing only specific branches in gitk

15.2.2. Working with simplified views

15.3. Studying files

15.3.1. Finding files of interest (git grep)

15.3.2. Examining the history of one file

15.4. Finding which revision updated a specific line of code

15.4.1. Running git blame as a GUI

15.4.2. Using git blame on the command line

15.5. Leaving messages for those who follow

15.6. Lab

15.7. Further exploration

15.8. Commands in this chapter

16. Understanding Git Rebase

16.1. Examining two git rebase use cases

16.1.1. Keeping up with the upstream by using git rebase

16.1.2. Cleaning up history by using git rebase

16.2. Examining use case 1: keeping up with the upstream

16.3. Using git reflog and git reset to revert your repo

16.4. Examining use case 2: cleaning up history

16.5. Lab

16.6. Further exploration

16.6.1. Cherry picking

16.6.2. Commit deleting

16.7. Commands in this chapter

17. Workflows and Branching Conventions

17.1. The need for Git conventions

17.1.1. Conventions for commits

17.1.2. Conventions for pushing code

17.1.3. Conventions for branching

17.1.4. Conventions for using rebase

17.1.5. Conventions for tagging

17.2. Two Git workflows

17.3. git-flow

17.3.1. Making a feature branch

17.3.2. Making a release branch

17.4. GitHub’s flow

17.5. Lab

17.6. Further exploration

17.7. Commands in this chapter

18. Working with GitHub

18.1. Understanding GitHub basics

18.1.1. Creating a GitHub account

18.1.2. Creating a repository

18.1.3. Interacting with the repository

18.2. Working with forks

18.2.1. Making a fork on GitHub

18.2.2. Cloning your fork

18.3. Collaborating with pull requests

18.3.1. Making a change to your fork

18.3.2. Making a pull request

18.3.3. Closing the pull request

18.4. Lab

18.5. Further exploration

18.6. Commands in this chapter

19. Third-Party Tools and Git

19.1. SourceTree

19.1.1. Installing SourceTree

19.1.2. Adding a repository into SourceTree

19.1.3. Staging a file

19.1.4. Tracking underlying Git commands in SourceTree

19.1.5. Committing a file in SourceTree

19.1.6. History view

19.2. Git and the Eclipse IDE

19.2.1. Installing Eclipse

19.2.2. Adding a repository into Eclipse

19.2.3. Staging and committing a file

19.2.4. History view

19.3. Other third-party tools

19.4. Lab

20. Sharpening your Git

20.1. Introducing the git config command

20.1.1. Using Git configuration variables

20.1.2. Understanding Git configuration order of precedence

20.1.3. Setting Git configurations temporarily

20.1.4. Setting Git configurations permanently

20.1.5. Resetting Git configurations

20.2. Working with Git configuration files

20.2.1. Editing Git configuration files

20.2.2. Using Git configuration file syntax

20.3. Configuring Git’s default editor

20.4. Configuring files to ignore

20.5. Continually learning Git

20.5.1. Work on a clone

20.5.2. Work with the help

20.5.3. Commit often

20.5.4. Collaborate

20.6. Lab

20.7. Commands in this chapter

About the book

Git is the source code control system preferred by modern development teams. Its decentralized architecture and lightning-fast branching let you concentrate on your code instead of tedious version control tasks. At first, Git may seem like a sprawling beast. Fortunately, to get started you just need to master a few essential techniques. Read on!

Learn Git in a Month of Lunches introduces the discipline of source code control using Git. Helpful for both newbies who have never used source control and busy pros, this book concentrates on the components of Git you?ll use every day. In easy-to-follow lessons that take an hour or less, you?ll dig into Git?s distributed collaboration model, along with core concepts like committing, branching, and merging. This book is a road map to the commands and processes you need to be instantly productive.

What's inside

  • Start from square one—no experience required
  • The most frequently used Git commands
  • Mental models that orient your brain to how Git works
  • Learn when and how to branch code

About the reader

No previous experience with Git or other source control systems is required.

About the author

Rick Umali uses Git daily as a developer and is a skilled consultant, trainer, and speaker.


Buy
combo $39.99 pBook + eBook + liveBook
eBook $31.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks

Do you think Git is hard to learn and manage? This book will change your mind.

Mohsen Mostafa Jokar, Hamshahri

The simplest way to become highly skilled at using Git. A must-read to make you more efficient very quickly.

Kathleen Estrada, Millersville University

Like being taught by a patient friend. The book is thorough without being stuffy, with clear explanations and well-crafted exercises.

Stuart Ellis, 27stars Ltd.

Git is the road you’ll need to take sooner or later. Why not start down the road while having your lunch?

Nacho Ormeño, Startupxplore