Search code examples
gitconfigurationgitignore

exclude file in Git Template directory does not work


I am trying to exclude all text documents in my dummy repo as what my textbook suggested. Using my desktop's GUI (and not the terminal), I copied and pasted the exclude file from the git-core git-core/templates/info into my own template file.

I then did echo "*.txt" > exclude

After that, I then ran this command git config --global init.templatedir C:/Users/youse/Documents/"Web Development" /learning_git/.git_template

As you can see, I made sure the path was absolute.

I then did git init and made a txt file in the repo, yet it still allows me to do git add. What did I do wrong here? There was a stackoverflow inquiry regarding this, and it talked about .gitignore. Forgive me, but I don't see a .gitignore

If anyone has an explanation, I would be very grateful.

On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        txt2.txt

nothing added to commit but untracked files present (use "git add" to track)


Solution

  • The file .git/info/exclude must contain just *.txt (*.txt^M$ in cat -Et output) — no quotes, no spaces.

    Now you need to fix your template repository and all repositories already created from the template. Manually, alas!