Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git .ignore not working in a directory

Tags:

git

I have the following .gitignore file

# file named .gitignore  system/application/config/database.php system/application/config/config.php system/logs modules/recaptcha/config/* 

However when I add any changes in config and recapcha.php, git status warns me as following. When I add any changes to database.php. it does not show it in status

shin@shin-Latitude-E5420:/var/www/myapp$ git status # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # # 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:   modules/recaptcha/config/recaptcha.php #   modified:   system/application/config/config.php # no changes added to commit (use "git add" and/or "git commit -a") 

How can I fix this?

Thanks in advance.

I am using git version 1.7.5.1 on Ubuntu 11.04

like image 640
shin Avatar asked May 17 '11 12:05

shin


People also ask

Why Gitignore is not working on a folder?

Git cannot ignore that even if you place its name or rule in the . gitignore file. So in essence, Git only ignores untracked files. You should look at your structure (repository) and make sure that the file which you are currently trying to ignore is not added to the repository.

Why is Gitignore not working in some files?

Some times, even if you haven't added some files to the repository, git seems to monitor them even after you add them to the . gitignore file. This is a caching issue that can occur and to fix it, you need to clear your cache.

Why is Gitignore not ignoring?

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.

Can Gitignore ignore folder?

gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.


1 Answers

The files are already stored in your local commit tree. You'll need to first remove them from the repository. This can be done via:

git rm --cached system/application/config/config.php modules/recaptcha/config/recaptcha.php 

After that you'll need to make one more commit and you're good to go.

like image 187
DipSwitch Avatar answered Oct 11 '22 09:10

DipSwitch