Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setup git to ignore index.php in root folder only and not all index.php files in subfolders

Tags:

git

I have .gitignore as

index.php
protected/config/

I wanted to ignore only index.php in root but git is ignoring all files with index.php in sub-folders as well. How I can modify .gitignore to ignore only specific index.php file and not all files with name index.php

like image 770
codescope Avatar asked Dec 08 '11 22:12

codescope


People also ask

Does Gitignore work in subfolders?

gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.

Does .gitignore need to be a the root folder?

gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple . gitignore files.

How do I ignore certain files in git?

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.


1 Answers

Use /index.php in your .gitignore

like image 89
Demian Brecht Avatar answered Nov 09 '22 20:11

Demian Brecht