Chapter 7

Writing and Committing Code

IN THIS CHAPTER

Bullet Committing code in a terminal

Bullet Creating a good commit

Bullet Writing a commit message

Bullet Committing other tools

In this chapter, you write and commit code. The first part, writing code, is a very broad topic — too broad to be covered in this (or any single) book. The code we write in this chapter sets the stage for covering how to create good commits. Most of this chapter focuses on committing code. No matter what kind of code you write, the act of committing that code remains the same.

The code example we use throughout this chapter may seem contrived and overly simplistic. That’s because it is contrived and simple. Don’t let the simplicity, though, distract you because the information in this chapter also applies to large code bases.

Creating a Repository

A commit is the smallest unit of work with Git. It represents a small logical group of related changes to the repository. A commit additionally represents a snapshot in time — the state of the entire repository can be represented by referencing a single commit.

Before writing code, ...

Get GitHub For Dummies now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.