Git ignore wwwroot?
# help-with-umbraco
p
Should the wwwroot folder be ignored or not?
h
That probably depends what you have in wwwroot, but in general I would include, it will contain your CSS and JavaScript for the frontend UI
p
yeah I figured
m
but not usually
media
πŸ˜‰
j
theres lots of different tools out there for creating gitnores but we've been using this one for a long while now: https://www.toptal.com/developers/gitignore?templates=visualstudio,visualstudiocode,umbraco,node you can build up a gitnore that works for your project - nice πŸ˜‰
t
Can recommend gitignore.io πŸ‘
m
there is also a case for ignoring any
app_plugins\*
from 3rd parties... as they should be treated as immutable (if not actually set by the developer) and delivered via nuget restore, for those that do still have physical files rather than the embedded resource approach.
k
+1 for the template gitignore, only ever made minor modifications to it.
j
+1 for @Mike Chambers comment re the
app_plugins
πŸ‘ the less stuff in the repo that should be coming from package restores etc the better!
one extra thing on this - if you store your media in the
wwwroot/media
folder and do a git clean, any files you've uploaded will be blow away... if you back up your local work as well, the media can add bloat to the backup... one way around this is to use the
UmbracoMediaPhysicalRootPath
app setting to control where the media is stored: https://docs.umbraco.com/umbraco-cms/v/13.latest-lts/reference/configuration/globalsettings#umbraco-media-physical-root-path e.g. we use user secrets so each dev can decide where the media is stored:
Copy code
{
  "Umbraco": {
    "CMS": {
      "Global": {
        "UmbracoMediaPhysicalRootPath": "C:\\work\\sitefiles\\ClientName\\media"
      }
    }
  }
}
means i can clean or blow away my local repo without the media that my local databases uses being blown away πŸ˜‰
s
> if you store your media in the wwwroot/media folder and do a git clean, any files you've uploaded will be blow away Not if you use the default Umbraco
.gitignore
, which has
/wwwroot/media
ignored. A git clean will only affect things that are not ignored.
j
interesting... just tried it... we have
**/wwwroot/media
in our
.gitnore
, i just checked out a repo, added a file to the media folder and ran the command i usually run to reset any local changes:
git clean -fxd
and the media files were deleted:
Copy code
$ git clean -fxd
Removing src/Base.Web/wwwroot/media/
am i using the wrong git command πŸ€”
s
Yeah.. you're ignoring the .gitignore πŸ˜… - don't add
x
! https://git-scm.com/docs/git-clean
Copy code
-x
Don’t use the standard ignore rules
j
ah! ok, weird - i've been using that command for literally years now without really thinking about it to reset my local copy of the repo back to the remote...
Copy code
-x
Don’t use the standard ignore rules (see gitignore[5]), but still use the ignore rules given with -e options from the command line. This allows removing all untracked files, including build products. This can be used (possibly in conjunction with git restore or git reset) to create a pristine working directory to test a clean build.
i think the
pristine working directory
may have been where this came from i.e. the local is 100% set back to what the remote would be so any files that are being ignored that maybe causing problems are canned? well there you go, learnt somit new today πŸ˜‰
m
Or use blob storage/s3 storage and share media across your environments & developers.
j
sadly here in australia our interwebs is pretty crappy... working from home i only have 100 down / 20 up which makes the latency between azure/amazon unpractical...
52 Views