- Building Enterprise JavaScript Applications
- Daniel Li
- 121字
- 2021-07-23 16:30:59
Staging our changes
By having a staging area, we can git add multiple related changes and git commit them all at the same time—as a single commit.
Here, the staging area acts as a temporary environment to collect these related changes. For example, if we add a new feature into our application, we should also document this in our README.md. These changes are related to each other and should be committed together:
$ echo "console.log('Hello World')" >> index.js
$ echo -e "# Usage\nRun \`node index.js\`" >> README.md
$ git add index.js README.md
$ git commit -m "Add main script and documentation"
[master cf3221a] Add main script and documentation
2 files changed, 3 insertions(+)
create mode 100644 index.js