说服git在vboxsf文件系统上正确处理符号链接 [英] Persuading git to handle symlinks correctly on vboxsf filesystem

查看:98
本文介绍了说服git在vboxsf文件系统上正确处理符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在vboxsf文件系统上git克隆带有符号链接的存储库时,所有符号链接都可以正常工作,但是git总是说文件已更新,即使更改已添加到存储库中.

When I git clone a repository with symlinks on a vboxsf filesystem the symlinks all work fine, but git always say that the file has been updated, even if the change is added to the repo.

当我在root上的ext4文件系统上使用它时,一切正常.

When I use it on the ext4 filesystem on root, everything works fine.

我正在Windows上使用Vagrant VM. vboxsf文件系统是用于与Windows主机共享的目录的类型.它能够支持符号链接(尽管底层文件系统在Windows上).

I am using a Vagrant VM on Windows. The vboxsf filesystem is the type used for a directory shared with the Windows host. It is capable of supporting symlinks (despite the underlying filesystem being on Windows).

$ git --version
git version 1.7.9.5
$ mount
--- snipped ---
vagrant-root on /vagrant type vboxsf (uid=1000,gid=1000,rw)
$ git init repo
Initialized empty Git repository in /vagrant/dev/repo/.git/
$ cd repo
$ echo foo > foo
$ ln -s foo bar
$ cat bar
foo
$ ls -l
total 1
lrwxrwxrwx 1 vagrant vagrant 0 Sep 12 17:34 bar -> foo
-rwxrwxrwx 1 vagrant vagrant 4 Sep 12 17:34 foo
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       bar
#       foo
nothing added to commit but untracked files present (use "git add" to track)
$ git add --all
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file:   bar
#       new file:   foo
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   bar
#
$ git commit -m "1st commit"
[master (root-commit) ec99b71] 1st commit
 2 files changed, 2 insertions(+)
 create mode 120000 bar
 create mode 100644 foo
$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   bar
#
no changes added to commit (use "git add" and/or "git commit -a")

升级到git v1.8.4后,我仍然得到相同的行为

I still get the same behaviour after upgrading to git v1.8.4

因此git似乎在克隆期间正确创建了符号链接,但是在提交文件时,它无法正确处理它们.

So it seems that git creates the symlinks properly during a clone, but then it fails to handle them correctly when the files are being committed.

是否有任何git设置可以帮助我说服git我奇怪的fs做符号链接?

Are there any git settings that will help me persuade git that my strange fs does do symlinks?

更新 我已经设法使git在Windows主机上的virtualbox共享文件夹文件系统(vboxsf)上正常工作(出于我的目的).

Update I have managed to get git working (for my purposes) on a virtualbox shared folder filesystem (vboxsf) with a Windows host.

  1. 以管理员身份运行Virtual Box-允许符号链接为 在主机文件系统上创建,因此允许来宾 文件系统来创建和使用符号链接
  2. 对每个符号链接使用git update-index --assume-unchanged.这样就可以提交其他文件,而无需git认为符号链接已更改.
  1. Run Virtual Box as Administrator - that allows symlinks to be created on the host filesystem and therefore allows the guest filesystem to create and use symlinks
  2. Use git update-index --assume-unchanged for each symlink. This allows other files to be committed, without git thinking that the symlinks have been changed.

问题

  1. 符号链接在Windows中不起作用(我不认为-尽管我不需要在那里使用它们, 所以没有尝试太多)
  2. 要创建新的符号链接或编辑旧的符号链接,我必须在ext4卷上进行.
  1. The symlinks don't work in Windows (I don't think - though I don't need to use them there, so haven't tried much)
  2. In order to create new symlinks or edit old ones, I have to do it on an ext4 volume.

推荐答案

基于mount输出,使用的是默认的同步文件夹,即VirtualBox的vboxsf.

Based on the mount output are using default synced folder, which is VirtualBox's vboxsf.

不确定您是否知道vboxsf不支持符号/硬链接,这可能会导致使用git出现问题.参见机票#818 ,它仍然没有固定.

Not sure if you are aware that vboxsf lacks support for symbolic / hard links, which will potentially cause problems using git. see the ticket #818 here, it is still not fixed.

因此,我将避免使用vboxsf,改用sshfs或NFS在主机和来宾之间共享文件和目录.

So I would avoid using vboxsf, use sshfs or NFS instead to share files and directories between host and guest.

注意:sshfs非常方便,我们将能够通过SSH挂载远程路径,并像使用本地路径一样使用它们.我还没有听说过vboxsf之类的git问题(但仍可能如此).

NOTE: sshfs is pretty handy, we will be able to mount remote path via SSH and use them as if they were local. I haven't heard of git issues like vboxsf (but could still be).

简单示例:

将远程ssh目录安装为sshfs => sudo sshfs user@host:~user /mnt/sshfs

mount remote ssh directory as sshfs => sudo sshfs user@host:~user /mnt/sshfs

unmount sshfs => sudo fusermount -u /mnt/sshfs

unmount sshfs => sudo fusermount -u /mnt/sshfs

这篇关于说服git在vboxsf文件系统上正确处理符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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