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

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

问题描述

我有一个Git Repository。我想将基于不同提交的资料库历史记录中的所有文件和文件夹导出到文件夹中。但我想单独导出所有提交和分支。我的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.

我该如何实现这一目标?是一个图形用户界面工具或类似的东西?我使用Windows机器。

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

推荐答案

您可以使用 git worktree< path> < 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天全站免登陆