Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Something like:

git config --global core.excludesfile ~/.gitignore-global echo .DS_Store >> ~/.gitignore-global



sort by: page size:

For what it's worth...

  echo ".DS_Store\n" >> ~/.gitignore
  git config --global core.excludesFile "~/.gitignore"

Put them into your global .gitignore

    echo -e >>~/.config/git/config '[core]\n    excludesFile = ~/.config/git/gitignore'
    echo >>~/.config/git/gitignore '.env'

For git users:

    echo ".DS_Store" >> ~/.gitignore
    git config --global core.excludesfile ~/.gitignore
If you spend many man hours dealing w/ .DS_Store files in source code repos you're doing something wrong.

Additionally git supports a global git ignore.

    $ git config --global core.excludesfile ~/.gitignore
Then you can put all the standard things you want to ignore into it:

    $ cat ~/.gitignore
    .DS_Store
    ./drafts/
    *.swp
And it will apply to all git commands on your computer.

Or simply put the file at the default location for core.excludefile, which is

    ~/.config/git/ignore 
on Unixy platforms.

git can be configured to ignore .DS_Store by default - in your home directory, make a .gitignore file using the usual format, then do "git config --global core.excludesfile ~/.gitignore".

lgtm.

A global .gitignore is one of the first things I install on a new machine - and then I never think of it again.

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

You might be interested in:

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

You can have a system-wide (but local only) .gitignore. It doesn't help other people who clone your repo, but it can be useful in some situations.


Great tip! Didn't know about this.

A similar one: ~/.config/git/ignore is a global private gitignore.

Great for files across repos which you always want to ignore, such as temporary files from an editor


> There should be a .local.gitignore to somesuch

I think .git/info/exclude is what you're looking for? (and also the global ~/.config/git/ignore)


Yes, that's what I'm already doing. The question is what to put as your core.excludesfile setting in the .gitconfig file.

You don't need to set core.excludesfile any more, it defaults to ~/.config/git/ignore these days

It's much better to ignore the files generated by your own tools with a global exclude file than to add them to every project's .gitignore.

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

Better still is to put it in ~/.config/git/ignore and leave your core.excludesFile unset, as that's the default path and will therefore live right next to your config file.

Yeah I've been using that for quite some time and it's incredibly useful.

You can also set a global ignore file, which you could set in one of your path based includes.

  [core]
    excludesfile = ~/.gitignoreglobal
https://github.com/sammcj/zsh-bootstrap/blob/master/.gitconf...

There's also .git/info/exclude:

> Patterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a .gitignore file.

> Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the $GIT_DIR/info/exclude file.

> Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.

https://git-scm.com/docs/gitignore


That's cool!

You can also put local gitignore rules in .git/info/exclude , but i have a hard time remembering that exact path for some reason.


Another comment already mentioned the `.git/info/exclude` directory. For completeness link to the online docs: https://git-scm.com/docs/gitignore

git will take 3 files into consideration for "ignoring" files:

> $XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore

How I use them:

* ~/.gitignore: stuff I want to ignore everywhere (`/myNotes`, `.DS_STORE`, ...)

* <project>/.gitignore: stuff that should be ignore for this projects and shared with others

* <project>/.git/info/exclude; stuff for this project that only I want to ignore

** this is also super useful in combination with `git-bisect`


By that logic it should be in your global excludes file. It practice it will save more time if you just add it to your project's .gitignore instead of wasting time having everyone else configure their system. O(1) amount of work compared to O(n)
next

Legal | privacy