Skip to contentSkip to conversation

User-wide ignore list

DISCUSSION Matthieu Moy 5 participants 11 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

Is there a way to have a per-user ignore list in git?

I'd like to ignore once and for all the backup files of my editor (*~), which are not necessarily relevant to a project, but definitely relevant for me regardless of the project.

Thanks,

Signature · 1 line
Matthieu
#1 lore raw
Quoted 1 line · Matthieu Moy

Is there a way to have a per-user ignore list in git?

Yep; in repository-layout.txt it says:

info/exclude::
This file, by convention among Porcelains, stores the exclude pattern list. .gitignore is the per-directory ignore file. git status, git add, git rm and git clean look at it but the core git commands do not look at it. See also: gitlink:git-ls-files[1] --exclude-from and --exclude-per-directory.

Andy

Signature · 2 lines
Dr Andy Parkins, M Eng (hons), MIEE
[email protected]
#2 lore raw

Hi,

Quoted 7 lines · Andy Parkins
Quoted 1 line · Matthieu Moy

Is there a way to have a per-user ignore list in git?

Yep; in repository-layout.txt it says:

info/exclude::

Nope. This is per-repo, not per-user.

Hth,
Dscho

#3 lore raw
Quoted 3 lines · Johannes Schindelin
Quoted 1 line

info/exclude::

Nope. This is per-repo, not per-user.

Silly me; I forgot to write the last bit of my email :-)

$ ln -sf $HOME/.git/exclude $GIT_DIR/info/exclude

Do that in each of your working checkouts and voila.

Andy

Signature · 2 lines
Dr Andy Parkins, M Eng (hons), MIEE
[email protected]
#4 lore raw

Hi,

Quoted 11 lines · Andy Parkins
Quoted 3 lines · Johannes Schindelin
Quoted 1 line

info/exclude::

Nope. This is per-repo, not per-user.

Silly me; I forgot to write the last bit of my email :-)

$ ln -sf $HOME/.git/exclude $GIT_DIR/info/exclude

Do that in each of your working checkouts and voila.

... and next time you edit .git/info/exclude, be very surprised that other repos have the change, too.

Ciao,
Dscho

#6 lore raw
Quoted 7 lines · Johannes Schindelin

Hi,

Quoted 1 line · Matthieu Moy

Is there a way to have a per-user ignore list in git?

It's not really per user, but how about doing it with templates?

It might be an option to introduce a configuration variable that points at a file to be used in addition to $GIT_DIR/info/exclude. Then you can set that variable in ~/.gitconfig.

#7 lore raw
In reply to Johannes Schindelin
Quoted 7 lines · Johannes Schindelin

Hi,

Quoted 1 line · Matthieu Moy

Is there a way to have a per-user ignore list in git?

It's not really per user, but how about doing it with templates?

Templates have no effect on previously created git repositories, does it?

Signature · 1 line
Duy
#8 lore raw
In reply to Johannes Schindelin
Quoted 7 lines · Johannes Schindelin

Hi,

Quoted 1 line · Matthieu Moy

Is there a way to have a per-user ignore list in git?

It's not really per user, but how about doing it with templates?

Correct me if I'm wrong (I didn't really find a documentation for templates), but I believe this would only apply to newly created project. Then, it doesn't apply if I clone the project of someone using another editor for example, nor to my old projects if I add something to the list of things I want to ignore.

Signature · 1 line
Matthieu
#9 lore raw

Hi,

[Cc'ed Duy, as he raised the same concerns.]

Quoted 11 lines · Matthieu Moy
Quoted 5 lines · Johannes Schindelin
Quoted 1 line · Matthieu Moy

Is there a way to have a per-user ignore list in git?

It's not really per user, but how about doing it with templates?

Correct me if I'm wrong (I didn't really find a documentation for templates), but I believe this would only apply to newly created project.

Yes. However, you can safely call "git init" in an _existing_ repo. It does not overwrite existing files.

Quoted 3 lines

Then, it doesn't apply if I clone the project of someone using another editor for example, nor to my old projects if I add something to the list of things I want to ignore.

"git clone" implicitly calls "git init"; Therefore you get the templates, too. But you're right, if you already edited .git/info/exclude, this will not overwrite it.

Of course, you could fiddle with ~/.gitconfig, or even ~/.gitignore, but I suggest that you first think about a sane syntax.

Also note that this opens the door for shooting-in-the-foot; files you are certain you want ignored can show up in a cloned repo all to easy.

Ciao,
Dscho

#10 lore raw
Quoted 2 lines · Johannes Schindelin

Yes. However, you can safely call "git init" in an _existing_ repo. It does not overwrite existing files.

Oh.. that's enough for me :-)

Signature · 1 line
Duy