1

I'm doing a git status and I have the following file that shows up in the "Changes not staged for commit"

/GTCS/External Assemblies/Alstom.ApplicationBroker.Toolkit.dll

So I added the exact text above to the .gitignore file.

But it still shows up in the Changes not staged for commit when I do a git status.

I think it is because of the space in the folder name External Assemblies or maybe the fact that I placed a forward slash at the beginning?

I tried putting a backwards slash immediately after the word External but that does not work. Always appears as not staged.

danglingpointer
  • 4,708
  • 3
  • 24
  • 42
Ray
  • 4,679
  • 10
  • 46
  • 92
  • See the solution from https://stackoverflow.com/questions/10213653/gitignore-ignore-files-within-a-folder-that-has-whitespace-in-the-middle This worked for me. – T. Marra May 30 '17 at 12:22
  • 1
    If it shows up as "changes not staged" rather than as an untracked file, then it's because git ignore rules only apply to untracked files (not to new changes to tracked files) regardless of any issues with spaces in the path – Mark Adelsberger May 30 '17 at 12:41

2 Answers2

2

If the file appears in the "Changes not staged for commit" area it means the file is already tracked by Git.

Git uses .gitignore only when adding new files to the repository (i.e. git add). Your file is already tracked, adding its name now in .gitignore doesn't change anything.

If you want to ignore the file when it is already tracked you have to:

  1. add its name/path to .gitignore and
  2. remove the file from the repository.

The second part is as easy as:

git rm --cached /GTCS/External Assemblies/Alstom.ApplicationBroker.Toolkit.dll

After you commit the removal the file will not appear in the output of git status any more.


N.B. The space in the name is not related in any way to the issue.

axiac
  • 68,258
  • 9
  • 99
  • 134
  • 2
    Note that this removes the .dll and prevents accidental re-adding of it (to commits that "see" the `.gitignore` entry), but does not remove it fully from the repo - i.e. it's still in history, taking up space and being readable by anyone with access to the repo. If OP needs the file entirely purged from the repo, that's a whole other can of worms – Mark Adelsberger May 30 '17 at 14:07
1

Try /GTCS/External\ Assemblies/Alstom.ApplicationBroker.Toolkit.dll. There should be a slash before the space.

Milan Chheda
  • 8,159
  • 3
  • 20
  • 35