2021-01-05 12:46:07 +01:00
|
|
|
title = Rename a file in the next commit
|
2021-01-11 19:16:35 +01:00
|
|
|
cards = add reset checkout-file mv commit
|
2021-01-05 12:46:07 +01:00
|
|
|
|
|
|
|
[description]
|
|
|
|
|
|
|
|
Other times, you might want to rename a file in the next commit. Use
|
|
|
|
|
|
|
|
git mv [file] [new name]
|
|
|
|
|
|
|
|
for that. The effect is very similar as if you had created a copy with a new name, and removed the old version.
|
|
|
|
|
|
|
|
[setup]
|
|
|
|
|
|
|
|
echo a > a
|
|
|
|
echo SPECIAL > 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 you rename the file b to "x".
|
|
|
|
test "$(git ls-tree --name-only main)" = "$(echo -e "a\nc\nx")"
|