3

I have a git repository where some files are not synchronized with git, but with rsync. These files are listed in a file rsynced.txt.

Is there a way that git ignores files listed in .gitignore plus files listed in rsynced.txt?

(looks like I could use the config option "core.excludeFiles", but it was not meant for this)

PlasmaBinturong
  • 2,122
  • 20
  • 24

1 Answers1

2

You would be correct in assuming you can use core.excludesfile:

git config core.excludesfile rsynced.txt

Call this inside the repo.

cuuupid
  • 912
  • 5
  • 20
  • This is a global level gitignore and thus, files that needed to be ignored for one particular repo will start getting untracked for all other repos. Read more here: https://help.github.com/articles/ignoring-files/ – prabodhprakash Sep 11 '17 at 17:24
  • 2
    Calling this option without `--global` does **NOT** affect global repos. I use this all the time in my repos. In the link you referenced it even uses `--global`. – cuuupid Sep 11 '17 at 17:25
  • 2
    Note that config settings are **local** only. They will not be pushed to the remote and will not automatically be applied to other users in their repos. If you want all users to ignore them, you'll need to add them to the gitignore file. Odds are these files can be described by a handful of patterns so you won't need to explicitly handle the list though. – LightBender Sep 11 '17 at 17:31
  • @LightBender is absolutely correct. If you're working on a team, I would highly recommend using `gitrc` and including a `.gitrc` file in the repo which can execute commands like these. – cuuupid Sep 11 '17 at 17:42
  • Doesn't that introduce the same problem? It requires the presence of an asset outside the repo in order to get consistent behavior? – LightBender Sep 11 '17 at 17:58
  • This solution would work I guess, but is quite a hack and not really scalable (you can not have another extra gitignore). I was hoping there was a "clean" git way of adding extra gitignore files, but it doesn't seem to exist... – PlasmaBinturong Sep 12 '17 at 14:09
  • Besides using .gitrc files I'm not sure there is another way. You could technically `cat rsynced.txt >> .gitignore` although that's manual. – cuuupid Sep 12 '17 at 15:24