Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore symbolic links in .gitignore

Is it possible to tell Git to ignore symlinks ? I'm working with a mixed Linux / Windows environment and, as you know, symlinks are handled very differently between the two.

like image 543
Andrei Avatar asked Aug 18 '10 10:08

Andrei


1 Answers

Use git version >= 1.6

Git used to treat sym-links the same as regular files, but newer git versions (>= 1.6) check if a file is beyond a symbolic link and will throw a fatal error.

e.g.:

# git init 
# mkdir newdir 
# touch newdir/foo 
# git add newdir/foo 
# git commit -m 'add foo' 
# mv newdir /tmp/ 
# ln -s /tmp/newdir 
# touch newdir/bar 
# git add newdir/bar 
fatal: 'newdir/bar' is beyond a symbolic link

# git add/tmp/newdir
fatal: '/tmp/newdir' is outside repository

# git --version
git version 1.7.3.4
like image 191
Tilo Avatar answered Oct 12 '22 00:10

Tilo