Git like a Pro

Content for this wiki is adapted from the Pro Git book, written by Scott Chacon and Ben Straub and published by Apress. https://git-scm.com/book/en/v2

Licence
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0 or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

Preface

Preface by Scott Chacon Welcome to the second edition of Pro Git. The first edition was publis...

What is Git?

So, what is Git in a nutshell? This is an important section to absorb, because if you understand ...

A Short History of Git

As with many great things in life, Git began with a bit of creative destruction and fiery controv...

Getting Started

This chapter will be about getting started with Git. We will begin by explaining some background ...

Git Basics

Getting a Git Repository

You typically obtain a Git repository in one of two ways: You can take a local directory th...

Recording Changes to the Repository

At this point, you should have a bona fide Git repository on your local machine, and a checkout o...

Checking the Status of Your Files

The main tool you use to determine which files are in which state is the git status command. If y...

Ignoring Files

Often, you’ll have a class of files that you don’t want Git to automatically add or even show you...

Viewing Your Staged and Unstaged Changes

If the git status command is too vague for you — you want to know exactly what you changed, not j...

Committing Your Changes

Now that your staging area is set up the way you want it, you can commit your changes. Remember t...

Skipping the Staging Area

Although it can be amazingly useful for crafting commits exactly how you want them, the staging a...

Removing Files

To remove a file from Git, you have to remove it from your tracked files (more accurately, remove...

Moving Files

Unlike many other VCS systems, Git doesn’t explicitly track file movement. If you rename a file i...

Viewing the Commit History

After you have created several commits, or if you have cloned a repository with an existing commi...

Limiting Log Output

In addition to output-formatting options, git log takes a number of useful limiting options; that...

Undoing Things

At any stage, you may want to undo something. Here, we’ll review a few basic tools for undoing ch...

Unstaging a Staged File

The next two sections demonstrate how to work with your staging area and working directory change...

Unmodifying a Modified File

What if you realize that you don’t want to keep your changes to the CONTRIBUTING.md file? How can...

Working with Remotes

To be able to collaborate on any Git project, you need to know how to manage your remote reposito...

Showing Your Remotes

To see which remote servers you have configured, you can run the git remote command. It lists the...

Adding Remote Repositories

We’ve mentioned and given some demonstrations of how the git clone command implicitly adds the or...

Fetching and Pulling from Your Remotes

As you just saw, to get data from your remote projects, you can run: $ git fetch <remote&...

Pushing to Your Remotes

When you have your project at a point that you want to share, you have to push it upstream. The c...

Inspecting a Remote

If you want to see more information about a particular remote, you can use the git remote show &l...

Renaming and Removing Remotes

You can run git remote rename to change a remote’s shortname. For instance, if you want to rename...