I know this is a bad practice but I changed the permission of /home and put a .gitignore there (I have a weird use case, let's keep it at that for now, will discuss more about it in the P.S.).
My .gitignore looks like:
/*
!/.gitignore
!/ismail/
/ismail/*
!/ismail/.zshrc
!/ismail/.searchmonkey/
/ismail/.searchmonkey/*
!/ismail/.searchmonkey/*
!/ismail/.config/
/ismail/.config/*
!/ismail/.config/user-dirs.dirs
!/ismail/.config/alacritty/
/ismail/.config/alacritty/*
!/ismail/.config/alacritty/alacritty.yml
The thing is this .gitignore does not work in /home , but works when I put it in /home/ismail/Desktop/test-git.
The permission of both directories:
/home/ismail/Desktop/test-git:master+%
total 20
drwxrwxr-x 4 ismail ismail 4096 Jun 6 12:26 .
drwxr-xr-x 3 ismail ismail 4096 Jun 6 12:24 ..
-rw-rw-r-- 1 ismail ismail 296 Jun 6 12:39 .gitignore
drwxrwxr-x 4 ismail ismail 4096 Jun 6 12:25 ismail
/home:master*+% ls -la
total 20
drwxrwxr-x 4 ismail ismail 4096 Jun 6 12:40 .
drwxr-xr-x 20 root root 4096 May 31 22:50 ..
-rw-rw-r-- 1 ismail ismail 2284 Jun 6 12:40 .gitignore
drwxrwxr-x 23 ismail ismail 4096 Jun 6 12:57 ismail
P.S. Please feel free to give any suggestion that meet my use case. My use case is, I track dotfiles of two linux distros. There are some common files and there are some distro specific files. So, my bare repos look like dotfiles_bare_repo_common, dotfiles_bare_repo_mint, dotfiles_bare_repo_zorin. So, for a given time, I need to put two .gitignore in /home/ismail (dotfiles_bare_repo_common and dotfiles_bare_repo_mint or dotfiles_bare_repo_common, dotfiles_bare_repo_zorin), which is not an option. So, I decided to move one step up and put common .gitignore in /home and distro specific .gitignore in /home/ismail, to maintain two .gitignore for same directory (.git/info/exclude does not work for me, as I need to push or clone the repos). I have also checked Can you set multiple gitignore files, in the same directory? and Are multiple .gitignores frowned on?. These also does not fit the bill.