问题描述
我昨天尝试安装git-annex来备份我的文件。我在我的资源库树的根目录下运行了 git annex add。
,然后运行了 git commit
。到目前为止,一切都很好。
我不知道git-annex所做的是将我的整个文件树变成一大堆符号链接。现在,我整个树中的每个文件都符号链接到 .git / annex / objects
!这是搞乱我的应用程序,这取决于文件不是符号链接。
我的问题是,如何摆脱git-annex并将我的文件系统恢复到原始状态州?对于一个正常的git仓库,我可以做 rm -r .git
,但是我担心在git-annex中不能完成这项工作。
好的,我偶然发现了一些,他们给出了两个命令来实现我想要做的事情:
我开始运行 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:
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存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!