3

I wanted to recently upload my dotnetnuke website on git, now my website has gigs of images which i don't want to upload over git.

I was searching on GIT and came across .gitignore file which gets created during repository creation, GIT has a documentation about ignorning files/folders and it's specific sub-folder, however it does not seems to work in my case.

Here's my folder structure:

*******Updated*******
.gitignore
public_html/Portals/_default/
public_html/Portals/0/
public_html/Portals/1/
public_html/Portals/110/

Now i want to ignore all folders under Portals except Portals/_default. I tried based on the specification from GIT:

Example to exclude everything except a specific directory foo/bar (note the /* - without the slash, the wildcard would also exclude everything within foo/bar):

    $ cat .gitignore
    # exclude everything except directory foo/bar
    /*
    !/foo
    /foo/*
    !/foo/bar

Below is what i tried:

!/Portals
/Portals/*
!/Portals/_default

But this does not seems to work at all.

Can anyone get me in right direction.

Abbas
  • 4,948
  • 31
  • 95
  • 161
  • 1
    Remove the first line, and remove the leading slashes (assuming the .gitignore file is adjacent to the Portals folder) – Plato Aug 27 '15 at 19:41
  • How does it not work according to your desires? – msw Aug 27 '15 at 19:43
  • @Plato: this does not works either, however i have updated my question to show full directory structure from root. – Abbas Aug 27 '15 at 20:06
  • 1
    Your problem seems to be the `public_html` folder. Move your gitignore into `public_html` or add the `public_html` folder to every line. – Johannes Thorn Aug 27 '15 at 20:30

1 Answers1

5

From the git documentation for gitignore:

Example to exclude everything except a specific directory foo/bar (note the /* - without the slash, the wildcard would also exclude everything within foo/bar):

$ cat .gitignore
# exclude everything except directory foo/bar
/*
!/foo
/foo/*

Tada!

msw
  • 42,753
  • 9
  • 87
  • 112