我有一个要在远程存储库中删除的文件夹。我想删除它,但将文件夹保留在我的计算机中
git rm --cached -r somedir
将暂存目录的删除,但不会触及磁盘上的任何内容。这也适用于文件,例如:
git rm --cached somefile.ext
之后,您可能希望将 somedir/
或 somefile.ext
添加到您的 .gitignore
文件中,以便 git 不会尝试将其添加回来。
我只想:
将文件夹移出工作树
git rm 文件夹,提交更改
添加到 .gitignore(或 .git/info/excludes),提交更改
将文件夹移回
git rm -r
git rm --cached path/to/file