Skip to main content

git addの取り消し

git addを取り消す(ファイルツリーは残す)

git reset

実行例: (Changes to be committed から Changes not staged for commit, Untracked files に変わる)

 ✘ ✝  repos/bdash/bdash-sources   BDAS-29--TERMS±  git status
On branch BDAS-29--TERMS
Your branch is up to date with 'origin/BDAS-29--TERMS'.

Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/app/[lang]/contact/page.tsx
modified: src/i18n/locales/ja/translation.json

✝  repos/bdash/bdash-sources   BDAS-29--TERMS±  git reset
Unstaged changes after reset:
M src/i18n/locales/ja/translation.json
✝  repos/bdash/bdash-sources   BDAS-29--TERMS±  git status
On branch BDAS-29--TERMS
Your branch is up to date with 'origin/BDAS-29--TERMS'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/i18n/locales/ja/translation.json

Untracked files:
(use "git add <file>..." to include in what will be committed)
src/app/[lang]/contact/

no changes added to commit (use "git add" and/or "git commit -a")

特定のファイルのみをgit addから取り消す場合は、以下のようにする

git rm --cached <file>