Is it possible to have a custom .gitignore? Read only access?

前端 未结 5 1525
生来不讨喜
生来不讨喜 2020-12-12 23:35

I am working in a team environment, and there is already a .gitignore file.

I want to add more items to the .gitignore file, but I don\'t w

5条回答
  •  一个人的身影
    2020-12-13 00:01

    I know I am a little late to the conversation but you might want to consider using

    git update-index --assume-unchanged [ FILE ]
    

    As the git help document states:

    When the "assume unchanged" bit is on, git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file...

    Emphasis mine. It goes on to say

    This option can be ... used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files). Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

    So just keep in mind that you will have to be aware of any upstream changes made to these files.

    In the event that you want to start tracking the file again all you have to do is use

    git update-index --no-assume-unchange [ FILE ]
    

    I hope this helps any future viewers of this post.

提交回复
热议问题