Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitIgnore - Ignoring bin/ but including bin/*.refresh

Tags:

git

gitignore

I'm trying to ignore the bin folder of a web project, but include the .refresh files that are in that bin folder.

Here's what I have in my .gitignore:

[Bb]in/
#Allow .refresh files for web sites
![Bb]in/*.refresh

But this isn't working. What am I doing wrong? I've also tried:

!*.refresh

With the same results.

Update:

Here's the file structure if that helps diagnose this:

\rootfolder
    .gitignore
    \project1
         \bin
              file1.dll
              file1.dll.refresh

You can see where our gitignore file is located. We don't want the .dll but we do want the .refresh file.

like image 370
Nicholas Head Avatar asked Nov 17 '11 23:11

Nicholas Head


People also ask

Why is my file not being ignored in Gitignore?

. gitignore only ignores files that are not part of the repository yet. If you already git add ed some files, their changes will still be tracked. To remove those files from your repository (but not from your file system) use git rm --cached on them.

How do I ignore a .gitignore file?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

Why Git ignore file is not working?

This is because Git can only ignore the untracked files. Thus, you need to check the repository and make sure that the file that you are trying to ignore is not added to the repository. If it is, you should remove the file from your repository, and then copy the contents of the file and add its name to . gitignore.


1 Answers

This way not worked for me:

[Bb]in/*
![Bb]in/*.refresh

I have used the syntax bellow on .gitignore file and worked fine.

Try it:

**/[Bb]in/*
!**/[Bb]in/*.refresh
like image 176
Leandro Sá Avatar answered Sep 23 '22 00:09

Leandro Sá