How to permanently prevent specific part of a file from being committed in git?

后端 未结 6 547
一个人的身影
一个人的身影 2020-12-10 04:07

I have cloned a remote SVN repository with git-svn. I have modified a pom.xml file in this cloned repo in a way that the code compiles. This setup is exclusive for me. Thus

6条回答
  •  独厮守ぢ
    2020-12-10 04:29

    There might be a possiblity with filters. But this needs to be explored more.

    Starting point: Implement the smudge / clean for this filter:

    git config --global filter.versionUpdate.smudge 'sed "s/14.5.0<\/version>/14.5.FEATURE-15<\/version>/"'
    git config --global filter.versionUpdate.clean 'sed "s/FEATURE-15<\/version>/14.5.0<\/version>/"'
    

    In this way, the file is always the same when comparing, since the filter is applied.

    Problem: It still needs investigation on how to find the filtered files back. This is not so evident in the working directory.

提交回复
热议问题