git mv file1 file2
git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: file1 -> file2
git stash
git stash pop
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: file2
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: file1
ご覧のとおり、git は stash / pop の後に名前が変更された関係を失います。この関係を回復する方法、またはファイルが移動されたことを stash に知らせる方法はありますか? 変更前のシステム状態を確認するために隠しておくことがよくありますが、名前変更の関係が失われることは私にとって問題です。新しいファイルを削除し、もう一度 git mv を実行し、新しいファイルの内容を置き換える以外に修正する方法がわかりません。