简体   繁体   中英

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.

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.

Try entering the following in your .gitignore:

/build

Another thing to try is

build/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM