Reputation: 22138
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
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
Reputation: 151
Another way to achieve this it is by adding a global git ignore and add this file pattern.
create a file out side all the repos
touch ~/.gitignore
git config --global core.excludesfile ~/.gitignore
Upvotes: 0
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
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