4.1 Adding Files

You’re constantly adding new files and making changes to your repository’s contents. git add fills both of these roles. Just give it the name of a file or the files you want to add, and Git stages the changes to commit.

Before we proceed, there is a little terminology to clear up. Staged changes are simply changes in your working tree that you want to tell your repository about. When you stage a change, it updates what Git refers to as its index. A lot of people, myself included, refer to it as the staging area.

The staging area is just that, a place where you can set up commits prior to committing to your repository.

“But isn’t this double the amount of work? Why can’t I just commit?”

In a lot of cases, yes, it is double ...

Get Pragmatic Version Control Using Git now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.