git - Is it possible to exclude file from `git push`, but keep them in the local repository?

前端 未结 5 1294
悲&欢浪女
悲&欢浪女 2020-12-13 09:44

In my home directory I have files in a local git repository, because I want track them all under version control.

Most of these files I want to push to a remote repo

5条回答
  •  粉色の甜心
    2020-12-13 10:10

    You can go ahead and actually track these files (sans the sensitive info), but then use:

    git update-index --assume-unchanged

    on each file. Then you can go ahead and add the sensitive info to each file, but Git will not see the file as changed, and not try to commit (and thus push) that sensitive info.

    To get Git to update the info again, you'd use:

    git update-index --no-assume-unchanged

提交回复
热议问题