Git: Exclude a file with git clean

前端 未结 5 1048
灰色年华
灰色年华 2020-12-14 14:45

i\'m working on a big python project, and i\'m really sick if .pyc and *~ files. I\'d like to remove them. I\'ve seen that the -X flag of git clean would remove

5条回答
  •  借酒劲吻你
    2020-12-14 15:07

    The difference is the capital X you're using. Use a small x instead of the capital one. Like in: git clean -x.

    git clean -x -n -e local_settings.py # Shows what would remove (-n flag)
    git clean -x -f -e local_settings.py # Removes it (note the -f flag)
    

    From the git documentation:

       -x
           Don't use the standard ignore rules read from .gitignore (per
           directory) and $GIT_DIR/info/exclude, but do still use the ignore
           rules given with -e options. This allows removing all untracked
           files, including build products. This can be used (possibly in
           conjunction with git reset) to create a pristine working directory
           to test a clean build.
    
       -X
           Remove only files ignored by git. This may be useful to rebuild
           everything from scratch, but keep manually created files.
    

提交回复
热议问题