tomferon
tomferon

Reputation: 5001

How to ignore a file in a Git repository without .gitignore nor a global setting?

I try to add a temporary-but-not-so-temporary file to a Git repository without adding it to the index. I don't want to add it to a .gitignore nor to a file like ~/.gitignore_global because it would just apply for a specific repository.

Is there any way to ignore a file to be indexed in a specific repository without indexing the very fact that I want to ignore it ?

Upvotes: 4

Views: 1127

Answers (2)

Highway of Life
Highway of Life

Reputation: 24301

Avoid running git add on the file you don't want in your repository or...

Local per-repo rules can be added to the .git/info/exclude file in your repo. These rules are not committed with the repo so they are not shared with others. This method can be used for locally-generated files that you don’t expect other users to generate, like files created by your editor.

Upvotes: 0

manojlds
manojlds

Reputation: 301037

You can place the ignore patterns in $GIT_DIR/info/exclude so that it will be applicable to only the repo and not every repo.

From the manual:

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the $GIT_DIR/info/exclude file.

Upvotes: 7

Related Questions