I started to use a git repo to backup config files, also in "/etc", using "/" as work-tree, and created an alias, called "git-backup", to this command:

git --work-tree=/ --git-dir=/home/user/repo/.git

This seems to work well for few years but now it's broken: I can't add file, well really can't add ".config" files, even with -f option; and if I try to add a folder inside home directory:

git-backup add src/linux-5.10.147
The following paths are ignored by one of your .gitignore files:
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"

I'm using

git-backup config --global core.excludesfile ~/.gitignore_global

and ".gitignore_global" file is:

# First, ignore everything
# Now, whitelist anything that's a directory
# And all the file types you're interested in.

The file ".git/info/exclude" has all lines commented out.

I'm using a repo with only readme file, I clone it, and point git-dir defined in the alias to the .git dir in the cloned repo.

Any advise or suggestions?


1 Answer 1


According to git documentation, your .gitignore file should not work:

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("") in front of the first "!" for patterns that begin with a literal "!", for example, "!important!.txt".

Try to change your .gitignore file to reinclude the directories themselves:

!/home          # Reinclude home ...
/home/*         # ... but exclude all sub-directories of home ...
!/home/user/*   # ... except user
  • thanks for point that out. Still can't get the user directory to be tracked. The problem could be related to alias definition?? Oct 22, 2022 at 14:19
  • From documentation: If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level. So if I have .gitignore_global inside user folder all path are relative to user folder? Oct 25, 2022 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.