How to get Git on Windows to ignore symbolic links How to get Git on Windows to ignore symbolic links windows windows

How to get Git on Windows to ignore symbolic links


You can do a checkout ignoring this single file like this:

git checkout HEAD . --no path/src

The .gitignore file only works for adding stuff to the index. Even a modifications on files commited before adding it to the .gitignore are not ignored.


I know this is late, but I ran into this issue.

In my case, I apparently had checked in my symlink at some point. So no matter what I did, .gitignore would not work (I think that is what Alexandre was getting at).

REPAIR:

  1. Remove all symlinks
  2. See if git now thinks there are deleted files to commit.
  3. If so, then go ahead and commit the deletions.

Now you can re-add your symlinks and .gitignore should work.


Here are my steps for this issue, similar, but a bit different from other answers.

Let's say I had a folder .fvm contain file.json and flutter_sdk(link) that all commited in git before, then I want to ignore out flutter_sdk.

  1. Add .fvm/flutter_sdk and .fvm/flutter_sdk/ in .gitignore.
  2. Cut .fvm/flutter_sdk out to other place than the repository.
  3. git add . and git commit ....
  4. Paste back the link.