The Git staging area, introduced in the previous chapter, is a powerful but, at the same time, confusing feature of Git. This chapter builds on what you’ve learned about the staging area, helping you to understand it better.
The staging area is used to add, delete, and rename files before they are committed into the repository. Any change to the repository goes through the staging area, which means you must come to grips with it. The commands that manipulate the staging area include git add, git rm, git mv, and git reset.
The staging area also provides the ability to commit parts of files to the repository. If you add debugging code or print statements, and don’t want to commit these into the repository, you can leave these out of the staging area without having to delete them from the file. This technique enables you to make more-refined commits and take control of your repository.
In Git, adding files to the repository is achieved via the git add and git commit commands. But what if you want to delete files from the repository? It turns out you follow a similar two-step pattern from the preceding chapter: git rm and git commit.
In the previous chapter, after you completed the lab, your working directory contained six files: a, b, c, d, math.sh, and readme.txt. The a, b, c, and d files were empty files that you created with the touch command.