从文件树中删除git-annex存储库 [英] Remove git-annex repository from file tree

查看:171
本文介绍了从文件树中删除git-annex存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天尝试安装git-annex来备份我的文件。我在我的资源库树的根目录下运行了 git annex add。,然后运行了 git commit 。到目前为止,一切都很好。



我不知道git-annex所做的是将我的整个文件树变成一大堆符号链接。现在,我整个树中的每个文件都符号链接到 .git / annex / objects !这是搞乱我的应用程序,这取决于文件不是符号链接。



我的问题是,如何摆脱git-annex并将我的文件系统恢复到原始状态州?对于一个正常的git仓库,我可以做 rm -r .git ,但是我担心在git-annex中不能完成这项工作。

解决方案

好的,我偶然发现了一些 docs for git-annex ,他们给出了两个命令来实现我想要做的事情:


unannex [路径...] 使用此命令可以撤销意外的git附加添加命令。你可以使用git annex unannex在任何时候将内容移出附件,即使你已经犯了它。
如果您故意附加文件并且不再需要其内容,则这不是您应该使用的命令。在这种情况下,您应该使用git annex drop来代替,并且您也可以将文件git r。



uninit



使用这个来停止使用git附件。它会取消存储库中的每个文件,并删除所有git-annex的其他数据,留下一个git存储库以及之前附加的文件。


我开始运行 git annex uninit ,但是我的上帝很慢。花了大约5分钟unannex只是一个文件。我的文件系统树大约有200,000个文件,所以这是不可接受的。



我最终做的事情实际上非常简单并且运行良好。我使用了 cp -rL 标志来自动复制我的文件树的内容并反转复制副本中的所有符号链接。它的速度非常快:我的整个文件树大约需要30秒。唯一的问题是,文件权限并未保留在原始状态,所以我需要运行一些 chmod chcon 命令修复权限。

第二种方法适用于我,因为我的模式中没有其他符号链接。如果你的模式中的符号链接超出了git-annex创建的那些符号链接,那么我的小捷径可能不是你的正确选择,你应该考虑坚持使用 git annex uninit


I tried installing git-annex yesterday to backup my files. I ran git annex add . in the root of my repository tree and then a git commit. So far everything is fine.

What I didn't know git-annex was doing was turning my entire file tree into a whole bunch of symlinks. Every single file in my whole tree is now symlinked into .git/annex/objects! This is messing up my application which depends on files not being symlinks.

My question is, how do I get rid of git-annex and restore my file system to its original state? For a normal git repo I could do rm -r .git, but I'm afraid that won't do the job in git-annex. Thanks in advance.

解决方案

Okay, so I stumbled upon some docs for git-annex, and they give two commands that achieve what I wanted to do:

unannex [path ...]

Use this to undo an accidental git annex add command. You can use git annex unannex to move content out of the annex at any point, even if you've already committed it. This is not the command you should use if you intentionally annexed a file and don't want its contents any more. In that case you should use git annex drop instead, and you can also git rm the file.

uninit

Use this to stop using git annex. It will unannex every file in the repository, and remove all of git-annex's other data, leaving you with a git repository plus the previously annexed files.

I started running git annex uninit, but my god was it slow. It took about 5 minutes to "unannex" just a single file. My filesystem tree is about 200,000 files, so that was just unacceptable.

What I ended up doing was actually surprisingly simple and worked well. I used the cp -rL flags to automatically duplicate the contents of my file tree and reverse all symlinks in the duplicate copy. And it was blazing fast: around 30 seconds for my entire file tree. Only problem was that the file permissions were not retained from my original state, so I needed to run some chmod and chcon commands to fix up the permissions.

This second method worked for me because there were no other symlinks in my schema. If you do have symlinks in your schema beyond those created by git-annex, then my little shortcut probably isn't the right choice for you, and you should consider sticking with just git annex uninit.

这篇关于从文件树中删除git-annex存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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