9

I've been working with git for a while myself, and am now setting up a repo for our team. We develop a eCommerce platform.

There are a few directories and files to be ignored, such as the upload directory and environment specific config files.

While the config files are on .gitignore, I'd like to ignore the uploads directory with either --skip-worktree or --assume-unchanged.

My question - which I couldn't find an explicit answer on - is if the --assume-unchanged or --skip-worktree bit will be pushed to the upstream repo?

If not, what would be the optimal way to ensure that git doesn't manipulate the contents of the uploads directory, across ALL instances of the repository?

jgangso
  • 638
  • 10
  • 19

1 Answers1

7

No, both --assume-unchaged and --skip-worktree is only used to mark the files in your local repository which you want to avoid committing or skip when scanning for changes.

If you want to ignore files globally in all repositories, the best way is to put the mask into .gitignore:

*.class         # will ignore all class files anywhere
/tmp/           # will ignore tmp directory but only in top directory
/config/prod/*  # will ignore all configuration files in /config/prod path
Zbynek Vyskovsky - kvr000
  • 18,186
  • 3
  • 35
  • 43
  • Thanks @kvr000 . But how is it then - I've understood that git doesn't respect the contents of the directories defined in .gitignore. That would mean git may swipe out the contents of those directories during checkout and similar actions. Have I understood correct? – jgangso Feb 17 '16 at 08:22
  • 1
    @jgangso : Not sure if I understand correctly the question. But git will ignore the files from `.gitignore` when both committing and pulling from remote repository. Those files will be always untouched. – Zbynek Vyskovsky - kvr000 Feb 17 '16 at 08:29
  • Yes, you understood correct. I tried to find the resource where I read that .gitignore would behave as I described above, to see if I had misunderstood something, but couldn't find it now. I'll set it up using .gitignore, which sounds correct to me. – jgangso Feb 17 '16 at 08:36
  • 12
    @ZbynekVyskovsky-kvr000 .`gitignore` will not work if the file is already present in the repository. While `--assumed-unchanged` and `--skip-worktree` do not work across all repos. Do we have a solution which takes care of both the problems ? – Swaroop Nov 27 '18 at 13:21