10

I looked into the official documentation

**/packages is supposed to remove file/directory packages from being tracked

I tried but without any luck I still see the following:

**********NOTE: THESE FILES ARE SYMLINKS*********

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)

modified:   src/main/resources/webapp/dart/packages/route_hierarchical
modified:   src/main/resources/webapp/dart/packages/shadow_dom
modified:   src/main/resources/webapp/dart/packages/source_maps

my complete .gitignore

target/
.idea
.DS_Store
session-store
*.iml
banzai_auth_cache.ser
banzai_rm_cache.ser
**/packages

These are the steps:

  • I clone the project with git clone I add gitignore and then
  • commit/push
  • I change the files under packages with "pub get", these files are symlinks
  • I see them when I do git status

Okay, I tried add

symlinks = false

to .git/config, without luck too. I'm looking and I will update my question if I find something

I also tried adding those symlinks one by one to git ignore

3 Answers3

16

You can try the following commands,

git rm --cached .
git add . 
git commit -m "refreshed ignored files."

Edit

Because of the git syntax you have to point to a folder with the rm command.

BierDav
  • 1,219
  • 1
  • 10
  • 27
mehmet6parmak
  • 4,777
  • 16
  • 50
  • 71
  • 5
    `git rm` requires that some path(s) be passed to it: `git rm --cached src/main/resources/webapp/dart/packages/*`. Also, the latter should be enough for the files in question to become ignored. No need to stage anything else or make a commit. – jub0bs Sep 15 '14 at 20:54
  • 1
    as the comment said git rm --cached requires file/files and folder location. else this helped solving an issue I have had. :) – Maytham Fahmi Dec 01 '17 at 12:29
  • 2
    This also works to remove the project's cache: git rm -r --cached ./ – lechat Nov 03 '20 at 13:47
3

.gitignore does not remove files that are already tracked but instead affects which files will be tracked by default when git add is run. After ignoring some files with .gitignore, you may want to run git rm --cached on files that are already tracked.

Sam Hartman
  • 6,210
  • 3
  • 23
  • 40
  • I actually re-cloned the project, added gitignore and then modified the files! still no luck, can't find my mistake –  Sep 15 '14 at 20:45
0

the symlinks have to be removed and committed first.

step 1: add the gitignore
step 2: delete all the symlinks
step 3: commit/push

from now on, they won't appear