不適切なファイルをgit addしてしまいました
weblog % git add content/posts/git-restore.md
weblog % git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: content/posts/git-restore.md
こういった場合 git reset <FILE>を使ってunstagedにしていました
が、上の例にもあるけど、git restoreを使えというサジェストが出ています
そもそも気がついたときのログにはadd/rmのサジェストも出ています
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
git add/rm: commitされた内容を更新するgit restore: working directoryの内容を破棄する
という違いがあるようです
今回のように間違ってaddしてしまった場合は、git restoreの方が正しそうです。
試してみます。
weblog % git restore --staged content/posts/git-restore.md
weblog % git status
On branch main
Your branch is up to date with 'origin/main'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
content/posts/git-restore.md
nothing added to commit but untracked files present (use "git add" to track)
無事に破棄ができました