Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell Git to ignore a specific filename only in the repository's top level? [duplicate]

Tags:

git

gitignore

Possible Duplicate:
How to exclude file only from root folder in GIT

For a specific JavaScript project, I am using the TinyWeb HTTP Server for local testing (to work around a specific security limitation that applies to file URLs). That program requires I have an index.html file in the root directory, but I do not want to commit that file to my Git repository.

How can I stop Git from bugging me about this "untracked file" on every commit? I do want to commit all index.html files located in subdirectories.

like image 262
PleaseStand Avatar asked May 29 '11 15:05

PleaseStand


People also ask

How do I ignore a specific file 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.

How do I configure git to ignore some files locally?

If you want to ignore certain files in a repository locally and not make the file part of any repository, edit . git/info/exclude inside your repository.


1 Answers

Add this to your .gitignore (in the root folder):

/index.html 

The leading / makes git use an absolute path (relative to the current .gitignore location), whereas all other lines are just treated as some kind of wildcard.

like image 180
poke Avatar answered Sep 21 '22 17:09

poke