关于git-lfs删除历史版本

这篇具有很好参考价值的文章主要介绍了关于git-lfs删除历史版本。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

git lfs prune [options]

Deletes local copies of LFS files which are old, thus freeing up disk
space. Prune operates by enumerating all the locally stored objects, and
then deleting any which are not referenced by at least ONE of the
following:

* the current checkout
* all existing stashes
* a 'recent branch'; see "Recent files"
* a 'recent commit' on the current branch or recent branches; see
  "Recent files"
* a commit which has not been pushed; see "Unpushed lfs files"
* any other worktree checkouts; see git  worktree

In general terms, prune will delete files you're not currently using and
which are not 'recent', so long as they've been pushed i.e. the local
copy is not the only one.

The reflog is not considered, only commits. Therefore LFS objects that
are only referenced by orphaned commits are always deleted.

Note: you should not run git lfs prune if you have different
repositories sharing the same custom storage directory; see
git lfs config for more details about lfs.storage option.

In your Git configuration or in a .lfsconfig file, you may set
lfs.fetchexclude to a comma-separated list of paths. If
lfs.fetchexclude is defined, then any Git LFS files whose paths match
one in that list will be pruned unless they are referenced by a stash or
an unpushed commit. Paths are matched using wildcard matching as per
gitignore(5).

Options:

--dry-run:
-d:
  Don't actually delete anything, just report on what would have been done
--force:
-f:
  Prune all objects except unpushed objects, including objects required for
  currently checked out refs. Implies --recent.
--recent:
  Prune even objects that would normally be preserved by the
  configuration options specified below in "Recent files".
--verify-remote:
-c:
  Contact the remote and check that copies of the files we would delete
  definitely exist before deleting. See "Verify remote".
--no-verify-remote:
  Disables remote verification if lfs.pruneverifyremotealways was enabled in
  settings. See "Verify remote".
--verbose:
-v:
  Report the full detail of what is/would be deleted.

Recent files
------------

Prune won't delete LFS files referenced by 'recent' commits, in case you
want to use them again without having to download. The definition of
'recent' is derived from the one used by git lfs fetch to download
recent objects with the --recent option, with an offset of a number of
days (default 3) to ensure that we always keep files you download for a
few days.

Here are the git  config settings that control this behaviour:

* lfs.pruneoffsetdays The number of extra days added to the fetch
  recent settings when using them to decide when to prune. So for a
  reference to be considered old enough to prune, it has to be this many
  days older than the oldest reference that would be downloaded via
  git lfs fetch --recent. Only used if the relevant fetch recent 'days'
  setting is non-zero. Default 3 days.
* lfs.fetchrecentrefsdays lfs.fetchrecentremoterefs
  lfs.fetchrecentcommitsdays These have the same meaning as
  git lfs fetch with the --recent option, they are used as a base for
  the offset above. Anything which falls outside of this offsetted window
  is considered old enough to prune. If a day value is zero, that
  condition is not used at all to retain objects and they will be pruned.

Unpushed lfs files
------------------

When the only copy of an LFS file is local, and it is still reachable
from any reference, that file can never be pruned, regardless of how old
it is.

To determine whether an LFS file has been pushed, we check the
difference between local refs and remote refs; where the local ref is
ahead, any LFS files referenced in those commits is unpushed and will
not be deleted. This works because the LFS pre-push hook always ensures
that LFS files are pushed before the remote branch is updated.

See "Default remote", for which remote is considered 'pushed' for
pruning purposes.

Verify remote
-------------

The --verify-remote option calls the remote to ensure that any LFS
files to be deleted have copies on the remote before actually deleting
them.

Usually the check performed by "Unpushed lfs files" is enough to
determine that files have been pushed, but if you want to be extra sure
at the expense of extra overhead you can make prune actually call the
remote API and verify the presence of the files you're about to delete
locally. See "Default remote" for which remote is checked.

You can make this behaviour the default by setting
lfs.pruneverifyremotealways to true.

In addition to the overhead of calling the remote, using this option
also requires prune to distinguish between totally unreachable files
(e.g. those that were added to the index but never committed, or
referenced only by orphaned commits), and files which are still
referenced, but by commits which are prunable. This makes the prune
process take longer.

Default remote
--------------

When identifying "Unpushed lfs files" and performing "Verify remote", a
single remote, 'origin', is normally used as the reference. This one
remote is considered canonical; even if you use multiple remotes, you
probably want to retain your local copies until they've made it to that
remote. 'origin' is used by default because that will usually be a main
central repo, or your fork of it - in both cases that's a valid remote
backup of your work. If origin doesn't exist then by default nothing
will be pruned because everything is treated as 'unpushed'.

You can alter the remote via git config: lfs.pruneremotetocheck. Set
this to a different remote name to check that one instead of 'origin'.文章来源地址https://www.toymoban.com/news/detail-799828.html

到了这里,关于关于git-lfs删除历史版本的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 要Git的文件太大,如何使用Git-LFS

    问题:要Git的文件太大 解决:使用Git-LFS,LFS原理这里不详说了 版本新一点的Git已经集成了Git-LFS, 不用单独去下载 。LFS的路径就在D:Program FilesGitmingw64bin,其中D:Program FilesGit是Git的安装目录。 如何用Git-LFS clone: 1、先打开一个文件夹,d:Desktop新建文件夹,cmd进入它(那

    2024年02月10日
    浏览(43)
  • 有Root与无Root安装git-lfs

    先查看arm还是AMD 例如当前使用Rocky Linux 8.8版本的内核。因此,应该下载适用于Rocky Linux 8.x的Git LFS安装包。 您可以按照以下步骤在Rocky Linux上安装Git LFS: 打开终端或命令提示符窗口。 使用以下命令下载适用于Rocky Linux 8.x的Git LFS安装包: 下载安装包后,使用以下命令安装Gi

    2024年02月16日
    浏览(53)
  • git-lfs安装及clone常见问题

    1.  安装git for windows-3.20版本,报错Could not find git; can not register Git LFS。 错误原因:可能这个版本有问题。参考:Could not find Git; can not register Git LFS. · Discussion #5031 · git-lfs/git-lfs · GitHub 解决方式:安装Git for Windows 2.36.1 2. 报错fatal: unable to access ‘https://github.com/.......‘: Op

    2023年04月08日
    浏览(42)
  • 如何用Git-LFS上传与下载大文件资源

    1.下载Git-LFS 2.安装到git目录下(根据你自己的git目录选择,若未安装git,先安装git) 2.1注册github完成访问网址,点击头像 点击个人简介即可进入进入个人主页  个人主页会显示仓库,点击右上角头像 2.2点击Your repositories 2.3点击NEW 2.4填写项目名称,描述,并添加README 点击创

    2024年04月22日
    浏览(35)
  • centOs安装git-lfs并下载huggingface模型

    hf模型都是用git-lfs托管的,可以直接git下载的,天才第一步: 1、安装git-lfs 2、直接git clone 3、测试模型opt-1.3b

    2024年02月12日
    浏览(54)
  • 无root权限安装git-lfs(linux版)

    首先给大家看一下官方链接:安装 Git Large File Storage - GitHub 文档 git-lfs/INSTALLING.md at main · git-lfs/git-lfs (github.com) 直接用这个命令好啦~绕了一大圈 以下是手动安装 接下来是我的步骤: 首先在本地点击此链接下载:https://github.com/git-lfs/git-lfs/releases/download/v3.2.0/git-lfs-linux-amd64-

    2024年01月20日
    浏览(51)
  • windows下安装使用git-lfs克隆大文件

    首先去git-lfs这里,下载相应平台的工具,我下载的windows版本,非安装版本,直接配置到系统环境变量里 执行以下命令验证是否成功 这样自动会下载里边的大文件 如果clone的时候还没有安装git-lfs,可以直接在项目目录里执行以下命令获取大文件

    2024年02月11日
    浏览(54)
  • linux下安装git-lfs的两种方法

    一、方法一(推荐) 首先安装git-lfs ubuntu版:  centeros版: 然后验证安装成功 若显示: 则安装成功。 二、方法二 从git官网上下载安装包后,手动解压后安装。 详细可参考: 安装 Git Large File Storage - GitHub 文档

    2024年02月07日
    浏览(41)
  • debian12部署Gitea服务之二——部署git-lfs

    初始化之后发现工作空间如下内容发生了变化: config文件增加了如下内容: [lfs]     repositoryformatversion = 0 跟踪大文件: 现在,你可以选择需要用Git LFS跟踪大文件,并将它们加入到Git LFS管理中。例如,如果你要跟踪所有 .mp4 文件,可以运行: git lfs track \\\"*.mp4\\\" 执行了上述命

    2024年03月08日
    浏览(39)
  • 如何下载github上用git-lfs工具下载的大文件

    要下载 GitHub 上使用 Git LFS 工具存储的大文件,您可以进行以下步骤: 安装 Git LFS:如果您的系统上没有安装 Git LFS,请先安装它。可以通过终端或命令行进行安装。 克隆存储库:使用以下命令克隆项目存储库到本地: 下载大文件:进入存储库目录,并使用以下命令下载大文

    2024年02月12日
    浏览(60)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包