Git: Ignore tracked files

前端 未结 3 1168
终归单人心
终归单人心 2020-11-27 08:49

I have some tracked files in a repository which are automatically modified when building the code. I don\'t want to untrack them, I just don\'t want them to appear as modifi

相关标签:
3条回答
  • 2020-11-27 09:44

    An another solution using git attributes and %f in filter command:

    git config filter.orig.clean "cat %f.orig"
    cp filename filename.orig
    echo "filename filter=orig" >> .git/info/attributes
    echo "filename.orig" >> .git/info/exclude
    
    0 讨论(0)
  • 2020-11-27 09:44

    Another approach (from a now deleted answer by Seth Robertson, but I found it helpful so resurrecting it) is to maintain a "tracked" template file, then have local untracked version of it, ex: "config.sample.ini" or "config.ini.template" see https://gist.github.com/canton7/1423106 for a full example.

    Then there won't be any concerns if the file is changed within git, etc. and you can use .gitignore (finally) on the local untracked files.

    0 讨论(0)
  • 2020-11-27 09:45

    Sure.

    git update-index --assume-unchanged [<file> ...]
    

    To undo and start tracking again:

    git update-index --no-assume-unchanged [<file> ...]
    
    0 讨论(0)
提交回复
热议问题