Search code examples
gitpowershellposh-git

Add content of all directories that have a specified name


For instance, we want to add the contents of all Media directories that Git has been told to ignore. The directories are scattered throughout our project. Running git add -A -f isn't a solution, because it adds everything. An alternative is to add each individually, though that would take some time like this:

git add /Path/To/Media/*
git add /Other/Path/To/Media/*

Solution

  • This is what worked for us in PowerShell.

    git add **/Media/* -f
    

    hvd points out that this only works on my environment (though I haven't confirmed this myself,) which is PowerShell on Windows 8.1.