Ray Kiddy
Ray Kiddy

Reputation: 3619

git is not ignoring an eclipse .version file

It may be something simple, but I cannot make git ignore this. I have put different combinations of things into the .gitignore file in the directory at the root of my repository.

But I still see:

 $ 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:   MyProject/build/.version

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

I have "build" in my .gitignore file. I have tried "MyProject/build/.version", "build/.version", ".version" and various combinations thereof. But perhaps not the right combination.

Upvotes: 0

Views: 144

Answers (2)

Eric Palace
Eric Palace

Reputation: 322

If you've only just added build to your .gitignore, then the files which were tracked before will still be tracked. .gitignore only prevents git from tracking new, untracked files which match the pattern given. To remove the file from git's history, without removing the file locally, you can run

git rm -r --cached build

to remove everything in the build directory, or

git rm --cached MyProject/build/.version

(or whatever the path is) to just remove the one file.

Upvotes: 2

Debajit
Debajit

Reputation: 47111

Try entering the following in your .gitignore:

/build

Another thing to try is

build/

Upvotes: 1

Related Questions