1

ファイルシステムにシンボリックリンクを含むリポジトリを git clone するとvboxsf、シンボリックリンクはすべて正常に機能しますが、変更がリポジトリに追加された場合でも、git は常にファイルが更新されたと表示します。

ext4ルートのファイルシステムで使用すると、すべて正常に動作します。

Windows で Vagrant VM を使用しています。vboxsf ファイルシステムは、Windows ホストと共有されるディレクトリに使用されるタイプです。シンボリックリンクをサポートできます (基礎となるファイルシステムが 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 にアップグレードした後も同じ動作が得られます

そのため、git はクローン中にシンボリック リンクを適切に作成しているように見えますが、ファイルがコミットされているときにシンボリック リンクを正しく処理できません。

私の奇妙なfsがシンボリックリンクを行うことをgitに納得させるのに役立つgit設定はありますか?

更新vboxsfWindowsホストを 使用して、仮想ボックス共有フォルダーファイルシステム( )で(私の目的のために)gitを動作させることができました。

  1. Virtual Box を管理者として実行 - これにより、ホスト ファイルシステムでシンボリック リンクを作成できるため、ゲスト ファイルシステムでシンボリック リンクを作成して使用できるようになります。
  2. git update-index --assume-unchanged各シンボリックリンクに使用します。gitこれにより、シンボリックリンクが変更されたと考えることなく、他のファイルをコミットできます。

問題

  1. シンボリックリンクはWindowsでは機能しません(私はそうは思いませんが、そこで使用する必要はないので、あまり試していません)
  2. 新しいシンボリック リンクを作成したり、古いシンボリック リンクを編集したりするには、ext4 ボリュームで行う必要があります。
4

1 に答える 1

0

出力に基づいて、mountVirtualBox のデフォルトの同期フォルダーを使用していますvboxsf

vboxsfシンボリック/ハードリンクのサポートが不足していることに気付いているかどうかはわかりません。これにより、git の使用に問題が発生する可能性があります。こちらのチケット #818を参照してください。まだ修正されていません。

したがって、ホストとゲストの間でファイルとディレクトリを共有するために、代わりにvboxsf、 useまたは NFS を使用することは避けます。sshfs

注:sshfsは非常に便利です。SSH 経由でリモート パスをマウントし、それらをローカルであるかのように使用できます。vboxsf のような git の問題については聞いたことがありません (まだそうかもしれません)。

簡単な例:

リモート ssh ディレクトリを sshfs としてマウント =>sudo sshfs user@host:~user /mnt/sshfs

sshfs をアンマウント =>sudo fusermount -u /mnt/sshfs

于 2013-09-13T01:28:44.110 に答える