Skip to content

will git add support symlinks file #4737

Answered by dscho
hyaray asked this question in Q&A
Discussion options

You must be logged in to vote

Assuming I have a file d:\a\1.txt with the content hello, and then I run git init in an empty folder d:\b. Following this, I create a symbolic link using mklink d:\b\1.txt d:\a\1.txt. Now, in the b folder, there is a 1.txt file, which is a symbolic link.

When I run git add . && git commit -am "update" and later check the file content using git show HEAD:1.txt, I observe that the content is d:\a\1.txt—the path of the source file. However, my expectation is to see the content as the string hello,

git show only shows what Git stores, which is the target of the symbolic link. It does not resolve the symbolic link because that does not make sense, as there is no D:\a\1.txt in the Git object …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@hyaray
Comment options

@zrrbite
Comment options

@dscho
Comment options

Answer selected by rimrul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #4735 on December 18, 2023 10:01.