2021-01-05 12:46:07 +01:00
title = Add new files to the index
2021-01-11 19:16:35 +01:00
cards = add commit
2021-01-05 12:46:07 +01:00
[description]
2021-02-04 12:01:58 +01:00
So far, when we made a commit, we've always recorded the current status of all objects, right?
2021-01-05 12:46:07 +01:00
2021-02-02 16:42:55 +01:00
But Git allows you to pick which changes you want to put in a commit!
2021-01-11 19:16:35 +01:00
2021-02-13 23:21:01 +01:00
To learn how that works, we need to learn about the "index"! In the index, we can prepare what will be in the next commit. In this game, the index is represented by a blue aura around icons in the file browser!
2021-01-05 12:46:07 +01:00
2021-02-04 12:01:58 +01:00
Initially, the index is empty. To make a commit that contains a new file, we need to add it!
2021-01-05 12:46:07 +01:00
[setup]
2021-02-02 16:42:55 +01:00
echo "The candle is burning with a blue flame." > candle
2021-01-05 12:46:07 +01:00
[win]
2021-02-02 16:42:55 +01:00
# Add the candle.
test "$(git diff --cached --name-only)" = "candle" || file -f .git/candle-added && touch .git/candle-added
2021-01-11 19:16:35 +01:00
2021-02-02 16:42:55 +01:00
# Make a commit.
test "$(git ls-tree --name-only HEAD)" = "candle"