Git file is beyond a symbolic link
Asked Answered
U

4

19

I've ran into an issue wherein Git believes that a file is beyond a symbolic link, and that, thus, it cannot be version controlled, but it appears to be a real file.

[root@r1 h]# stat -f conf/core-site.xml 
  File: "conf/core-site.xml"
    ID: 5c7eb82882a6e866 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 2735511    Free: 510158     Available: 371202
Inodes: Total: 694960     Free: 597972

Additionally, I've tried "readlink" to show the link pointer, but to no avail.

How does Git determine if a file is a symbolic link or not?

Ungrudging answered 9/2, 2013 at 1:11 Comment(5)
btw this is running in a virtualized environment, not sure that this will make a difference, but i figured id add it as a detail.Ungrudging
what is the error message? what is the output of git status?Goldenrod
stat -f shows information for the file system, not a particular file. So that output isn't really relevant.Wesson
Well, my question was indirectly answered below - it turns out that files behind a symlink directory are, themselves, not displayed as symlinks by "stat -f"Ungrudging
PSA: namei -l conf/core-site.xml (from util-linux package) is an oddly named yet very handy command for such investigations: it lists type, permissions, name (similar to ls -l) for each dir/symlink/file in the chain the OS needs to resolve a given path.Iseult
P
7

/project/subproject/conf

If you need to add the /conf into the main project and add symlinks for subprojects,

  1. Remove conf from subproject and add to the project, and commit changes.
$ cp /project/subproject/conf /project
$ rm /project/subproject/conf
$ commit changes    
  1. Then add the symlink and commit
$ cd /project/subproject/
$ ln -s ../conf/ conf
$ commit changes
Proctology answered 20/4, 2018 at 8:0 Comment(0)
C
1

Git shows that message for a file /this/is/my/file in case any of the dirs in the path or the file itself are symlinks. In your case the file is real, but maybe "conf" dir is a symlink.

Solution: find the right path for the file and run git add on the real file

Caramelize answered 16/7, 2020 at 9:29 Comment(1)
Git must be support the symbolic links, many files maybe far from the repo, but the repo needs their current content, this is an awkward attitude after all those yearsChlorine
N
0

I meet the problem when I want to modify a file in node_modules of js project. Lastly I place an effective file in my js folder and reference it. I remove the original module dependency.

Nunatak answered 2/6, 2022 at 16:7 Comment(0)
C
0

If you are using a GUI for Git, please do git add . in command line before committing it in the GitHub GUI or SourceTree.

Codpiece answered 8/7 at 7:8 Comment(2)
Did you reproduce the behavior? It seems to me that you don't answer the question ("How does Git determine if a file is a symbolic link or not?") and your suggestion also likely doesn't solve the problem.Juline
Currently the only solution that worked for me --> +1.Whilst

© 2022 - 2024 — McMap. All rights reserved.