I have a git repository which (for some reasons) contains some symbolic links (in unix-like operating systems). However, after I cloned it, each symbolic link is checked out as a regular text file containing the symbolic link destination. How should I let git checkout the links correctly?
A sample run of my command is attached below. In /tmp/a
, path
is a symbolic link to /some/path
. However, in /tmp/b
, the path
is a regular file.
[user@host /tmp]$ mkdir a
[user@host /tmp]$ cd a
[user@host /tmp/a]$ git init
Initialized empty Git repository in /tmp/a/.git/
[user@host /tmp/a]$ ln -s /some/path
[user@host /tmp/a]$ git add path
[user@host /tmp/a]$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: path
[user@host /tmp/a]$ git commit -m 'add path'
[master (root-commit) 8e726b6] add path
1 file changed, 1 insertion(+)
create mode 120000 path
[user@host /tmp/a]$ ls -l
total 0
lrwxrwxrwx. 1 user group 10 Sep 17 14:35 path -> /some/path
[user@host /tmp/a]$ cd ..
[user@host /tmp]$ git clone file:///tmp/a/.git b
...
[user@host /tmp]$ cd b
[user@host /tmp/b]$ ls -l
total 4
-rw-rw-r--. 1 user group 10 Sep 17 14:36 path
[user@host /tmp/b]$ cat path
/some/path[user@host /tmp/b]$
[user@host /tmp/b]$