2021-01-05 12:46:07 +01:00
|
|
|
title = Delete a file in the next commit
|
2021-01-11 19:16:35 +01:00
|
|
|
cards = add reset checkout-file rm file-delete commit
|
2021-01-05 12:46:07 +01:00
|
|
|
|
|
|
|
[description]
|
|
|
|
|
|
|
|
If you want to remove a file in the next commit, you can use `git rm`! This will both delete the file locally, and in the index.
|
|
|
|
|
|
|
|
If a file is modified, you'll need to reset these changes first/reset the files.
|
|
|
|
|
|
|
|
[setup]
|
|
|
|
|
|
|
|
echo a > a
|
|
|
|
echo x > b
|
|
|
|
echo x > c
|
|
|
|
git add .
|
|
|
|
git commit -m "Initial commit"
|
|
|
|
echo x > a
|
|
|
|
echo b > b
|
|
|
|
git add b
|
|
|
|
|
|
|
|
[win]
|
|
|
|
|
|
|
|
# Make a commit where all files are deleted ¯\_(^_^)_/¯
|
|
|
|
test "$(git ls-tree main | wc -l)" -eq 0
|