git ignore specific directories

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.

  • Can a file added to the index be retrieved?
  • how to view git notes attached to blob objects in eGIT
  • Dealing with previous commits when open-sourcing a project
  • git push subdirectory up on pushing to github?
  • Why “git cvsimport” only returns an empty Git repo?
  • Git Switching branch
  • 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.

  • Git local branch accessible for coworker
  • Integrating Git Slave With Jenkins
  • eclipse errors when try to change to master git branch
  • How to enable Version Control window in android studio
  • Git cherry pick vs rebase
  • git fsck misses to report a tree object as unreachable
  • One Solution collect form web for “git ignore specific directories”

    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!

    Git Baby is a git and github fan, let's start git clone.