One other option is to just use a pattern that matches everything, i.e: echo '*' > .gitignore And take advantage that ignore rules do not apply to tracked files. So instead of using an explicit .gitonly, you add files using: git add -f <file_to_be_included> All files should be ignored except the ones that were forcibly added. If needed, git ls-files can be used to list either category. Cheers, Rafael Ascensão