git lfs prune 从 lfs 中删除文件并推送到源

标签 git version-control bitbucket git-lfs

事情是这样的:

  1. 不小心提交了很多本不该提交的文件。
  2. 是否执行了 git reset --soft HEAD~2 以返回到事故发生前的提交
  3. 修改 gitignore 以忽略文件
  4. 再次提交并推送到原点。

我假设 git reset 会撤销意外提交的所有内容,但在检查了 bitbucket 的 git lfs 文件列表后,似乎所有来自意外提交的 lfs 跟踪文件都被推到了 lfs 中。如果我查看 bitbucket 中的源代码,这些文件不存在。

所以我尝试执行 git lfs prune,这似乎删除了一些文件,看起来大约是意外提交的数量,然后 git lfs push origin master .再次检查了 bitbucket 的 git lfs 文件列表,但那些文件仍然存在,并且原始文件没有任何变化。

我做错了什么?

最佳答案

doesn't appear to be a standard way of doing this :

The Git LFS command-line client doesn't support pruning files from the server, so how you delete them depends on your hosting provider.

比特桶allows you to delete LFS files using its web UI (在继续之前阅读整个链接页面):

Delete individual LFS files from your repository

It's important to understand that:

  • The delete operation described here is destructive – there's no way to recover the LFS files referenced by the deleted LFS pointer files (it's not like the git remove command!) – so you'll want to back up the LFS files first.
  • Deleting an LFS file only deletes it from the remote storage. All reference pointers stored in your Git repo will remain.
  • No branch, tag or revision will be able to reference the LFS files in future. If you attempt to check out a branch, tag or revision that includes a pointer file referencing a deleted LFS file, you'll get a download error and the check out will fail.

A repository admin can delete Git LFS files from a repo as follows:

  1. Go to the Settings page for the repo and click Git LFS to view the list of all LFS files in that repo.
  2. Delete the LFS files using the actions menu.

令人惊讶的是,从 GitHub 删除 LFS 文件的唯一方法似乎是 delete and recreate the repository 、丢失问题、星级、 fork 和可能的其他数据。

关于git lfs prune 从 lfs 中删除文件并推送到源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45924258/

相关文章:

linux - 如何设置 git 仓库的根目录为 vi/vim 查找路径?

具有多个不同 Remote 的 git 工作流程

windows - Windows 上的 Git : could not create leading directories error

svn - 从 SVN 中删除(忘记)一个文件?

svn - 仍然使用 CVS 的任何理由?

比特桶云 : Enable Auto Fork Sync

git - 如何更改 BitBucket 中的上游 repo 协议(protocol)?

git - 为什么无论我是否运行 git add,当我切换分支(修改、添加、删除文件)时,git 一直显示我的更改?

bitbucket - 无法使用 Sourcetree 验证我的 Bitbucket 服务器帐户/如何使用 Bitbucket 服务器凭据在源树中注册

svn - 哪个 SCM 可以轻松处理 90,000 个文件