2

I have a private git repo, access with ssh. ( eg git@myhost.com:/home/git )

There is a PHP project in it. My develop & deploy machine is both linux. It's works well for about half a year.

But these days, when I run git pull(or clone to other place), files in project root "becomes" symbolic link.

Hard to explain. So paste these:


ls -al

Some of output:

drwxr-xr-x 10 nginx nginx 4096 Jan 20 22:08 App
drwxr-xr-x 10 nginx nginx 4096 Jan 20 22:08 .git
drwxr-xr-x 10 nginx nginx 4096 Jan 20 22:08 Core
lrwxrwxrwx 10 nginx nginx 4096 Jan 20 22:06 index.php -> <?phpdefine('APP_PATH','./App');define(..........(FULL content OF index.php)
lrwxrwxrwx 10 nginx nginx 4096 Jan 20 22:08 .gitignore -> # ide.idea#temp files_runtime*.log..........(FULL content OF gitignore)

I know linux symbollic link is a file that contains the "target file path" and have a special "flag".

Every time I pull/reset , git will mark these files as symbollic links (which is really a normal file), and I don't know how to remove that flag.

This only occurs for files in project root (beside .git dir), for ALL of them.

Can someone help me with what's happened to my git repo?

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
GongT
  • 131
  • 1
  • 10

2 Answers2

1

You could try and confirm all those files are symlinks with:

 git ls-files -s ./aFile
 120000 1596f9db1b9610f238b78dd168ae33faa2dec15c 0       aFile

You should see them with a 120000 mode in the index, referencing an hash of the actual object content, which you can see with a:

git cat-file -p 1596f9db1

See "What does git do to files that are a symbolic link?"

You could try and restore all the files that way (removing the file from the index, recreating with the content of the cat-file -p command).

But I would rather check the history of the repo and see if I cannot reset to a state where those files were recorded as actual files, instead of symlinks.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I think I found the reason.....

I'm using both WebStorm & PhpStorm on the same project.

Two IDE using different version of plugins and different workspace staus (opened files etc)

So the .idea directory must different, I make another dir, soft link all file&folders except ".idea" in the project root to another dir.

Normaly I use PhpStrom's Git gui to upload my files, Weeks ago, I push a commit using WebStorm .

Finally, I get my files back using:

find . -maxdepth 1 -type l -exec bash -c -t 'mv "{}" "{}".bak ; readlink "{}.bak">"{}" ; rm -f "{}.bak"' \;

GongT
  • 131
  • 1
  • 10