Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting git to follow symlinks (again)

Tags:

Somebody already asked how you can get git to follow symlinks. There was an answer for a symlinked directory, but not for a symlinked file. It was also over a year ago.

Question: how do you get git to follow a symlink and add the file it refers to?

Here is the old question: How can I get git to follow symlinks?. There's also a question about what git typically does How does git handle symbolic links?. I'm after a way of changing this behaviour.

In case you care: I'm running git 1.5.4.3 on unix and git version 1.6.0 on mac.

like image 726
Peter Avatar asked Sep 30 '09 21:09

Peter


People also ask

Does Git maintain symlinks?

Git can track symlinks as well as any other text files. After all, as the documentation says, a symbolic link is nothing but a file with special mode containing the path to the referenced file.

How does Git deal with symlinks?

Git just stores the contents of the link (i.e. the aforementioned path of the file system object that it links to) in a 'blob' just like it would for any other file. It then stores the name, mode and type (including the fact that it is a symlink) in the tree object that represents its containing directory.

Does du follow symlinks?

The -L option tells du to process symbolic links by using the file or directory which the symbolic link references, rather than the link itself.

Can you commit symlinks?

Unfortunately after committing into Git, they've turned into plain text files. Note that even after committing and pushing into Git, the symlinks still work fine. However, after some branch switches and code merges, the symlinks become actual text files with the link target as the contents.


1 Answers

I'm pretty sure there's no way.

Additionally, it sounds like a kind of insecure, undefined behavior - what should it do when you move between versions of the file and it needs to write to it? In particular, if you check out a revision before it was added, do you really want it to remove the contents of a file outside the repository? What happens if you come back to present and recreate the file, or if the symlink itself is modified - should git also track the symlink itself?

Things along these lines were said on the git mailing list late last year in response to essentially the same question.

like image 185
Cascabel Avatar answered Sep 18 '22 09:09

Cascabel