2021-01-05 12:46:07 +01:00
|
|
|
title = Resetting files in the index
|
2021-01-11 19:16:35 +01:00
|
|
|
cards = add reset commit
|
2021-01-05 12:46:07 +01:00
|
|
|
|
|
|
|
[description]
|
|
|
|
|
2021-01-11 19:16:35 +01:00
|
|
|
See the dark shadow behind the icons? That's the version of the commit you're at!
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
|
|
|
echo a > a
|
|
|
|
echo b > b
|
|
|
|
echo c > c
|
|
|
|
git add .
|
|
|
|
git commit -m "Initial commit"
|
|
|
|
echo x > a
|
|
|
|
echo x > b
|
2021-01-11 19:16:35 +01:00
|
|
|
echo x > c
|
2021-01-05 12:46:07 +01:00
|
|
|
git add .
|
|
|
|
|
|
|
|
[win]
|
|
|
|
|
2021-01-11 19:16:35 +01:00
|
|
|
# Reset the changes in a and c
|
|
|
|
test "$(git show :a)" == "a" &&
|
|
|
|
test "$(git show :b)" != "a" &&
|
|
|
|
test "$(git show :c)" == "c"
|
|
|
|
|
|
|
|
# And make a commit!
|
|
|
|
test "$(git show main:a)" == "a" &&
|
|
|
|
test "$(git show main:b)" != "b" &&
|
|
|
|
test "$(git show main:c)" == "c"
|