事情是这样的:
- 不小心提交了很多本不该提交的文件。
- 是否执行了
git reset --soft HEAD~2
以返回到事故发生前的提交 - 修改 gitignore 以忽略文件
- 再次提交并推送到原点。
我假设 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:
- Go to the Settings page for the repo and click Git LFS to view the list of all LFS files in that repo.
- 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/