从存储库中删除文件但将其保留在本地

发布于 2024-09-13 22:09:41 字数 45 浏览 4 评论 0原文

我想在远程存储库中删除一个文件夹。我想删除它,但将该文件夹保留在我的计算机中

I have a folder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不回头走下去 2024-09-20 22:09:41
git rm --cached -r somedir

将暂存目录的删除,但不会触及磁盘上的任何内容。这也适用于文件,例如:

git rm --cached somefile.ext

之后您可能需要将 somedir/somefile.ext 添加到您的 .gitignore 文件中,以便 git不会尝试将其添加回来。

git rm --cached -r somedir

Will stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like:

git rm --cached somefile.ext

Afterwards you may want to add somedir/ or somefile.ext to your .gitignore file so that git doesn't try to add it back.

攒眉千度 2024-09-20 22:09:41

我只想:

  • 将文件夹移出工作树
  • git rm 文件夹,提交更改
  • 添加到 .gitignore (或 .git/info/excludes< /code>),提交更改
  • 将文件夹移回

I would just:

  • Move the folder out of your working tree
  • git rm the folder, commit the change
  • Add to .gitignore (or .git/info/excludes), commit the change
  • Move the folder back
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文