Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't my global .gitignore file ignore?

Tags:

gitignore

$ cat ~/.gitconfig [core]         editor = vim         excludefiles = /home/augustin/.gitignore $ cat ~/.gitignore toto $ mkdir git_test $ cd git_test/ $ git init $ touch toto $ git status  # On branch master # # Initial commit # # Untracked files: #   (use "git add <file>..." to include in what will be committed) # #       toto nothing added to commit but untracked files present (use "git add" to track) $ git --version git version 1.6.3.3 

Why isn't toto being ignored?

Other settings in ~/.gitconfig are taken into account (colors, editor).

like image 896
augustin Avatar asked Mar 11 '11 09:03

augustin


People also ask

Why is my file not being ignored in Gitignore?

gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them.

Is there a global git ignore?

You can set up a global . gitignore file that lists files that will be ignored on all Git projects. This is the preferred way of ignoring editor artifacts, toolchain log files, OS files, and other miscellaneous crap.

How do I force git to ignore a file?

Use Git update-index to ignore changes Or, you can temporarily stop tracking a file and have Git ignore changes to the file by using the git update-index command with the assume-unchanged flag.

Is there a global gitignore file in Git?

1 Answer 1. The gitignore man page doesn't mention of a global gitignore file. But if the latter doesn't work, that might be because those files were previously added to the Git repo, in which case you must rm them.

Why are my gitignore files not working?

Sometimes .gitignore files don't work even though they're correct. The reason Git ignores files is that they are not added to the repository. If you added a file that you want to ignore before, it will be tracked by Git, and any skipping matching rules will be skipped. Git does this because the file is already part of the repository.

How do I make Git ignore a file?

To make .gitignore work, you have to ensure that the file should not be part of the repository yet. The file won’t be ignored once it is already added to the repository. Even if you have changed its name or rule in the .gitignore file, Git can’t ignore it. This is because Git can only ignore the untracked files.

How do I set up a global gitignore rule?

First, create a .gitignore file for your global rules. Most people keep this in their home directory. Next, open it with your text editor of choice and add whatever files and folders you always want to ignore. Here’s what my global configuration looks like:


1 Answers

git config --global core.excludesfile ~/.gitignore

like image 147
sakisk Avatar answered Sep 20 '22 05:09

sakisk