I know the question is a bit cryptic, I couldn't word it exactly in a single sentence (might need some help on that).
I initialized git in my home directory (i.e, ~/, on Arch Linux) to backup my dot-files (mainly configs). I want to include every file and folder in it except the ones starting with a . (like .config/ and .bashrc).
So I made a .gitignore file whose contents are:
# Ignore everything
*
# Except these files and folders
!.*
But the problem is when I list all the untracked files (git status), it doesn't list the .config/ directory for some reason. I tried playing around with .gitignore and adding
!*/
shows all directories including .config/ and also Documents, Downloads etc, which I don't want to include.
And instead adding
!.*/
shows every other directory that starts with a . like .cache/, .vim/ etc. But for some reason the .config/ doesn't show up.
I even tried
!.config/
and
!.config
it doesn't work. The only thing that works is !*/ (all directories, which is not what I want)
Any way to solve this. Its really annoying.
[Solved]: it was a bug
The bug has been fixed in git version 2.34.1
Check the accepted answer.
CodePudding user response:
TL;DR
After the bug fix, you'll want what you put in your "kinda solved" section, or something similar. I think you'll want what I put in my "bottom line" section, really:
/*
!/.*
Long
As jthill noted in a comment, there is a bug in the .gitignore wildcard handling in Git 2.34.0, which will be fixed in 2.34.1. In this case I think the bug is making your wildcarding work better than it would otherwise, though.
