如何从 Git 存储库中提取任何提交到文件夹/存档的所有文件? [英] How to extract all files of any commit to a folder/archive from a Git Repository?

查看:41
本文介绍了如何从 Git 存储库中提取任何提交到文件夹/存档的所有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Git 存储库.我想根据不同的提交将存储库历史记录中的所有文件和文件夹导出到一个文件夹中.但我想分别导出所有提交和分支.我的 git 存储库的一种备份/存档.

I have a Git Repository. I want to export all files and folders from my repository history, based on the different commits, into a folder. But I want to export all commits and branches separately. A sort of backup/archive for my git repository.

例如,如果我有以下存储库历史记录:

For example if I have a repository history of:

-v2.0 我的最新提交 -v1.0 我的初始提交

-v2.0 My Latest commit -v1.0 My Initial commit

我想将这些不同提交的所有文件和文件夹导出到单独的文件夹中.我希望这些文件是正常的完整文件,而不是差异补丁.

I want to export all files and folders of these different commits into separate folders. I want the files as normal complete files not as a difference patch.

例如文件夹/MyGitBackup/Master/v1.0"和/MyGitBackup/Master/v2.0"应该包含相应提交的文件.

For example the folders "/MyGitBackup/Master/v1.0" and "/MyGitBackup/Master/v2.0" which should include the files of the according commits.

我怎样才能做到这一点?GUI工具是否能够做到这一点或类似的东西?我使用的是 Windows 机器.

How can I achieve this? Is a GUI tool capable of this or something similar? I use a Windows machine.

推荐答案

你可以使用 git worktree <commit> 能够检出不同目录的不同提交.因此,在您的工作目录中执行以下命令:

You can use git worktree <path> <commit> that enables to checkout different commits to different directories. So, execute the following commands in your working directory:

git worktree add /MyGitBackup/Master/v1.0 <v1.0 commit hash or tag>
git worktree add /MyGitBackup/Master/v2.0 <v2.0 commit hash or tag>

这篇关于如何从 Git 存储库中提取任何提交到文件夹/存档的所有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆