-2

I have a repository, and the .gitignore is right under the repository.

When I do a git status, there's annoying file src/main/resource/git.properties that keeps showing up, and sometimes blocks me from doing a git pull.

I searched that .gitignore can help, so I added the path src/main/resource/git.properties to the top of the file. if I do a cat .gitignore, it gives

src/main/resource/git.properties
logs/*.log

I also did git config --global core.excludesfile .gitignore

Then I do git status,

On branch master
Your branch is up-to-date with 'origin/master'.

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

    modified:   .gitignore
    modified:   src/main/resources/git.properties

no changes added to commit (use "git add" and/or "git commit -a")

What I expected was doing git status would say there's no change to the master.

Help please.

user2751691
  • 383
  • 2
  • 7
  • 28
  • 2
    Could it be the difference between `resource` and `resources`? – Mark Ransom Jun 29 '15 at 21:54
  • 1
    I don't think `git config --global core.excludesfile .gitignore` is correct - this is supposed to be an absolute path to a single instance of a file on your whole system. I'd suggest taking that out (maybe manually edit your global git config to do so) – M.M Jun 29 '15 at 21:54
  • possible duplicate of [Stop tracking and ignore changes to a file in Git](http://stackoverflow.com/questions/936249/stop-tracking-and-ignore-changes-to-a-file-in-git) – Sascha Wolf Jun 30 '15 at 07:27
  • This is a very frequent question on the [tag:git] tag, please ensure to properly search for a solution next time. – Sascha Wolf Jun 30 '15 at 07:28

1 Answers1

1

The .gitignore file does not affect files that are already checked in to the repository. You will have to do two things:

  • delete src/main/resource/git.properties

  • add it to .gitignore

Once both changes are committed, it won't show up in Git any more, even if the file exists on the file system.

The use of git config --global core.excludesfile .gitignore is unusual... I would remove that from your global config file. Normally you would specify a global excludes file, one with an absolute path, which applies to all directories. You don't need this, because the ordinary .gitignore should work fine.

Dietrich Epp
  • 182,361
  • 34
  • 307
  • 387