How to ignore several directories in Git

I’m going to be uploading several files to a community Git project, and I am only supposed to upload certain files without permission, then ask for permission to upload all the rest should I need to change them. So, I would like Git to just ignore all the directories I don’t have permission to freely change, so I can freely upload what I want, and then should the need arise, upload the directories I’ve changed that I don’t have permission to.

What would be the best way about doing this?

  • Why can't i rebase a merged topic branch?
  • Submitting huge patchset to mailing list
  • Jenkins Github Plugin - Triggering a Parameterized Build
  • Is there a way to have a patch that is never commited, only changes the working copy?
  • SOA Webservices - How to manage individual service development on Git
  • Trying to clone a repo to Windows 7 that has an 'aux' directory in it
  • Gitlab custom hook not running
  • Git Post Receive Hook: update current working branch to staging server
  • GitCloneTask doesn't clone repository (“The remote end hung up unexpectedly”)
  • Git: hide commit messages on remote repo
  • git-svn clone | spurious branches
  • How to amend a specific commit message in Git?
  • One Solution collect form web for “How to ignore several directories in Git”

    If those directories (you don’t have permission to change directly) are already versioned, I wouldn’t recommend a .gitignore solution as:

    • you risk to add, commit and push that .gitignore (which the remote repo doesn’t want to change)
    • it wouldn’t work anyway, without removing those folders from the index (git rm -r --cached /folders/you/dont/have/permission), which in turn risk to be committed and push (the remote repo wants those folders!)

    It is best to apply a local solution (which doesn’t risk to be pushed by mistake).

    Before adding anything, do (for the folder you don’t have permission) a:

    git update-index --skip-worktree -- /folder
    

    See “using git skip-worktree to disable file updates”.
    Your git status, git add and git commit should ignore that already versioned folder, even if you have modified/added files in it.

    You can reverse that local change with a:

    git update-index --no-skip-worktree -- /folder
    
    Git Baby is a git and github fan, let's start git clone.