.gitignore for all except Jenkins job config files

I’m using this .gitignore in the Jenkins directory:

#Ignore everything
*
#Don't ignore directories
!*/
#Don't ignore these files
!/.gitignore
!jobs/*/config.xml
!jobs/**/modules**/config.xml

But .gitignore files in subfolders aren’t ignored. I want to except only the root .gitignore.

  • Detaching a directory to be modified as a branch elsewere using Git
  • Know when a line of code was added to a GitHub repository
  • Can you use a branch in a forked repository as the base branch for a Github PR against upstream?
  • git describe: inexplicable commit count
  • Pushing projects to different GIT repositories
  • Does git usage degrade if there are excessive commits?
  • What is the state of distributed bug tracking?
  • Git, How to reset origin/master to a commit?
  • Can’t clone repo from GitLab CI in Docker
  • Why git doesn't push tags by default?
  • how to tell egit to ignore some file types
  • Synchronizing local git forked repo branches with changes from remote original
  • One Solution collect form web for “.gitignore for all except Jenkins job config files”

    !/.gitignore tells to ignore the file in your system root.

    You probably mean !./.gitignore, the one in your Jenkins root.

    But .gitignore files in subfolders aren’t ignored. I want to except
    only the root .gitignore.

    First you say they are not ignored, then that you don’t want to ignore them? My guess is that you meant to only ignore the .gitignore in your Jenkins root directory, but didn’t manage. In that case, try the above (!./.gitignore).

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