按时间顺序将多个文件夹提交到git [英] commiting multiple folders in chronological order into git

查看:89
本文介绍了按时间顺序将多个文件夹提交到git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站的数百个备份,每个文件夹一个.我想将它们放入git存储库中,每个备份都作为一个版本.所做的更改主要涉及每天的图像文件和2个数据库备份.大小大约为25 GB,并且正在增加.
有没有办法告诉git拿一个文件夹并将其提交到存储库,然后拿到下一个文件夹并提交更改,直到所有更改都提交了?还是我必须将每个文件夹复制到第一个文件夹,然后提交并继续下一个文件夹?
相同的文件在文件夹之间进行硬链接.
我想使用时间戳记提交每个备份,但据我了解,我可以在每次提交时提供它.
因此,我一直在寻找的主要信息实际上是关于指定不属于git存储库一部分的文件夹并将更改提交到存储库中.

I have several hundred backups of a web site, one per folder. I want to put them into a git repository, each backup as a version. The changes concern mostly image files and 2 database backups per day. The size is around 25 GB an increasing.
Is there a way to tell git to take one of the folders and commit it into the repository, then take the next folder an commit the changes, until they are all commited? Or do I have to copy each folder into the first folder, commit and continue with next folder?
Identical files are hardlinked between folders.
I would like to commit each backup with it's timestamps, but as far as I understand I can supply that with each commit.
So the main information I was looking for is really about specifying a folder not part of the git repository an committing the changes into the repository.

推荐答案

是否可以告诉git提取其中一个文件夹并将其提交到存储库中,然后取出下一个文件夹并提交更改

Is there a way to tell git to take one of the folders and commit it into the repository, then take the next folder an commit the changes

没有简单自动方式,但是有半自动方式.您必须操纵GIT_WORK_TREE或选项--work-tree.像这样的东西:

There is no a simple automatic way, but there is a semi-automatic way. You have to manipulate GIT_WORK_TREE or option --work-tree. Something like that:

cd first-version
git init
git add .
git commit -m "first-version"
git --work-tree=../second-version add -A
git commit -m "second-version"

,然后对每个目录重复此操作.如果所有目录都有常规名称,则可以运行循环:

and repeat for every directory. If all directories have regular, names you can run a loop:

for version_dir in ../*-version; do
    git --work-tree=$version_dir add -A
    git commit -m "$version_dir"
done

我想将它们的时间戳提交给他们

I would like to commit them with their timestamps

git不保留文件/目录的时间戳,仅保留提交的时间戳.

git doesn't preserve timestamps of files/directories, only of commits.

这篇关于按时间顺序将多个文件夹提交到git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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