I'd like to use git to backup my ~/.config folder, and I would like to just upload specific folders. My goal is to make my ~/.config folder into a Git Repo and adding a ~/.config/.gitignore
that allows me to just do git add . && git commit
, and just having a hand selected set of folders committed to the Repo.
Now my Problem is, that when I try to make a .gitignore
that ignores everything and then excludes the selected Directorys from that, git just ignores everything and does not care about the Directories I'm trying to be not ignored.
Here's my .gitignore
:
*
!.gitignore
!Jetbrains/**
!Google/**
!autostart/**
!git/**
!nvim/**
!obsidian/**
!polybar/**
CodePudding user response:
According to the .gitignore
rules, unanchored patterns are applied at every level, and an ignored directory will never even be scanned. So:
/*/
!/Jetbrains
!/Google
!/autostart
and so forth. "Ignore all toplevel directories" followed by "except these", and none of those patterns matches anything else.