Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
コマンド「git add dir」を使用して誤ってファイルを追加しました。「git commit」はまだ実行していません。このディレクトリとその中に含まれるすべてのものをコミットから削除する方法はありますか?
試してみgit reset dirましたが、うまくいきませんでした。どうやらgit reset fileそれを元に戻す方法です。しかし、私には非常に多くのファイルがあり、時間がほとんどありません。
git reset dir
git reset file
ディレクトリとその中のすべてをインデックスから削除するには、
git rm --cached -r dir
--cachedスイッチはインデックスgit rmのみを操作し、作業コピーには触れません。スイッチは-rそれを再帰的にします。
--cached
git rm
-r
とを使用findしxargsます。
find
xargs
find dir -type f | xargs git reset