Vitim.us
Vitim.us

Reputation: 22138

Are there any default extension or filename that is git ignored by default?

I'm wondering if there's any pattern that is ignored by git without any previous .gitignore file has been created locally or globally?

I need to run a script that temporarily creates a file inside directories, but I don't want it to be committed by accident, editing the gitignore in this case is not an option.

One idea is create files inside the .git folder, is this safe or there's any change that I would break git?

Upvotes: 2

Views: 2744

Answers (5)

ElpieKay
ElpieKay

Reputation: 30868

It's okay to create files in .git so that they won't be committed. But there is a risk that the reserved files in .git might be edited or deleted by accident and therefore the repository gets corrupted. Another option is to create files outside the repository and I think the system temporary folder is a safer place.

Upvotes: 0

Esha
Esha

Reputation: 151

Another way to achieve this it is by adding a global git ignore and add this file pattern.

  1. create a file out side all the repos

    touch ~/.gitignore

  2. add the pattern inside this file
  3. set the git config to use this file git config --global core.excludesfile ~/.gitignore

Upvotes: 0

eftshift0
eftshift0

Reputation: 30212

You can use .git/info/exclude so that it's only for that repo.

Upvotes: 2

o11c
o11c

Reputation: 16056

.git is un-addable at all levels. You can safely create a new directory called .git anywhere inside the repository, and you don't have to worry about messing with the real .git directory.

Upvotes: 2

jhill515
jhill515

Reputation: 943

Answering the actual question, kinda... Only the .git folder is ignored by default. All others are deamed potentially important for the source-base unless configured otherwise within the repository or at a global level.

The only reason why this is a "kinda" answer is because the .git folder contains the repository history and is therefore managed by git itself. Though you can safely add some files to .git, it can be risky.

Upvotes: 1

Related Questions