2021-01-05 12:46:07 +01:00
|
|
|
title = Resetting files in the index
|
2021-01-14 11:26:21 +01:00
|
|
|
cards = add reset-file commit
|
2021-01-05 12:46:07 +01:00
|
|
|
|
|
|
|
[description]
|
|
|
|
|
2021-02-04 12:01:58 +01:00
|
|
|
See the dark shadow behind the icons? That's the version of the file in the last commit!
|
|
|
|
|
|
|
|
For example, these candles have been blown out, and that change has been added.
|
|
|
|
|
|
|
|
But you decide that this was a mistake! You only want to blow out the red candle in the next commit!
|
2021-01-11 19:16:35 +01:00
|
|
|
|
|
|
|
If you already have updated the index to a changed file, but want to reset it, you can use `git reset`!
|
2021-01-05 12:46:07 +01:00
|
|
|
|
|
|
|
[setup]
|
|
|
|
|
2021-02-04 12:01:58 +01:00
|
|
|
echo "It's burning!" > red_candle
|
|
|
|
echo "It's burning!" > green_candle
|
|
|
|
echo "It's burning!" > blue_candle
|
2021-01-05 12:46:07 +01:00
|
|
|
git add .
|
2021-02-04 12:01:58 +01:00
|
|
|
git commit -m "The beginning"
|
|
|
|
|
|
|
|
echo "It's been blown out." > red_candle
|
|
|
|
echo "It's been blown out." > green_candle
|
|
|
|
echo "It's been blown out." > blue_candle
|
2021-01-05 12:46:07 +01:00
|
|
|
git add .
|
|
|
|
|
|
|
|
[win]
|
|
|
|
|
2021-02-04 12:01:58 +01:00
|
|
|
# Reset the changes in the green and blue candles!
|
|
|
|
git show :green_candle | grep burning &&
|
|
|
|
git show :blue_candle | grep burning &&
|
|
|
|
git show :red_candle | grep -v burning
|
2021-01-11 19:16:35 +01:00
|
|
|
|
|
|
|
# And make a commit!
|
2021-02-04 12:01:58 +01:00
|
|
|
git show main:green_candle | grep burning &&
|
|
|
|
git show main:blue_candle | grep burning &&
|
|
|
|
git show main:red_candle | grep -v burning
|