Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

134 total results found

Git Generally Only Adds Data

Git like a Pro Getting Started

When you do actions in Git, nearly all of them only add data to the Git database. It is hard to get the system to do anything that is not undoable or to make it erase data in any way. As with any VCS, you can lose or mess up changes you haven’t committed yet, ...

The Three States

Git like a Pro Getting Started

Pay attention now — here is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in: committed, modified, and staged: Committed means that the data is safe...

The Command Line

Git like a Pro Getting Started

There are a lot of different ways to use Git. There are the original command-line tools, and there are many graphical user interfaces of varying capabilities. For this book, we will be using Git on the command line. For one, the command line is the only place ...

Installing Git

Git like a Pro Getting Started

Before you start using Git, you have to make it available on your computer. Even if it’s already installed, it’s probably a good idea to update to the latest version. You can either install it as a package or via another installer, or download the source code ...

First-Time Git Setup

Git like a Pro Getting Started

Now that you have Git on your system, you’ll want to do a few things to customize your Git environment. You should have to do these things only once on any given computer; they’ll stick around between upgrades. You can also change them at any time by running t...

Getting a Git Repository

Git like a Pro Git Basics

You typically obtain a Git repository in one of two ways: You can take a local directory that is currently not under version control, and turn it into a Git repository, or You can clone an existing Git repository from elsewhere. In either case...

Recording Changes to the Repository

Git like a Pro Git Basics

At this point, you should have a bona fide Git repository on your local machine, and a checkout or working copy of all of its files in front of you. Typically, you’ll want to start making changes and committing snapshots of those changes into your repository e...

Checking the Status of Your Files

Git like a Pro Git Basics

The main tool you use to determine which files are in which state is the git status command. If you run this command directly after a clone, you should see something like this: $ git status On branch master Your branch is up-to-date with 'origin/m...

Ignoring Files

Git like a Pro Git Basics

Often, you’ll have a class of files that you don’t want Git to automatically add or even show you as being untracked. These are generally automatically generated files such as log files or files produced by your build system. In such cases, you can create a fi...

Viewing Your Staged and Unstaged Changes

Git like a Pro Git Basics

If the git status command is too vague for you — you want to know exactly what you changed, not just which files were changed — you can use the git diff command. We’ll cover git diff in more detail later, but you’ll probably use it most often to answer these t...

Committing Your Changes

Git like a Pro Git Basics

Now that your staging area is set up the way you want it, you can commit your changes. Remember that anything that is still unstaged — any files you have created or modified that you haven’t run git add on since you edited them — won’t go into this commit. The...

Skipping the Staging Area

Git like a Pro Git Basics

Although it can be amazingly useful for crafting commits exactly how you want them, the staging area is sometimes a bit more complex than you need in your workflow. If you want to skip the staging area, Git provides a simple shortcut. Adding the -a option to t...

Removing Files

Git like a Pro Git Basics

To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. The git rm command does that, and also removes the file from your working directory so you don’t see it as an untracke...

Moving Files

Git like a Pro Git Basics

Unlike many other VCS systems, Git doesn’t explicitly track file movement. If you rename a file in Git, no metadata is stored in Git that tells it you renamed the file. However, Git is pretty smart about figuring that out after the fact — we’ll deal with detec...

Viewing the Commit History

Git like a Pro Git Basics

After you have created several commits, or if you have cloned a repository with an existing commit history, you’ll probably want to look back to see what has happened. The most basic and powerful tool to do this is the git logcommand. These examples use a ver...

Limiting Log Output

Git like a Pro Git Basics

In addition to output-formatting options, git log takes a number of useful limiting options; that is, options that let you show only a subset of commits. You’ve seen one such option already — the -2 option, which displays only the last two commits. In fact, yo...

Undoing Things

Git like a Pro Git Basics

At any stage, you may want to undo something. Here, we’ll review a few basic tools for undoing changes that you’ve made. Be careful, because you can’t always undo some of these undos. This is one of the few areas in Git where you may lose some work if you do i...

Unstaging a Staged File

Git like a Pro Git Basics

The next two sections demonstrate how to work with your staging area and working directory changes. The nice part is that the command you use to determine the state of those two areas also reminds you how to undo changes to them. For example, let’s say you’ve ...

Unmodifying a Modified File

Git like a Pro Git Basics

What if you realize that you don’t want to keep your changes to the CONTRIBUTING.md file? How can you easily unmodify it — revert it back to what it looked like when you last committed (or initially cloned, or however you got it into your working directory)? L...

Working with Remotes

Git like a Pro Git Basics

To be able to collaborate on any Git project, you need to know how to manage your remote repositories. Remote repositories are versions of your project that are hosted on the Internet or network somewhere. You can have several of them, each of which generally ...

remotes