How to stop tracking a file without removing it from repo

后端 未结 4 1181
醉话见心
醉话见心 2021-01-30 11:11

I have a config file which I want to keep on the remote repository, but I don\'t want to track its changes on my computer. Adding it to .gitignore doesn\'t do the trick.

<
4条回答
  •  独厮守ぢ
    2021-01-30 11:21

    You will need to do the combination of .gitignore file and git rm --cached. Use the following command :

    git rm --cached filename.txt

    This will remove the file from indexing but it will keep it in your repository and working area. After applying rm --cached you will need to commit the changes for it to take effect. It will show as Deleted in your tracked changes, but that's only because it has been deleted from indexing. Note: If you make changes to it again in future commits you will have to run: git rm --cached to untrack the changes to the file from the particular commit.

提交回复
热议问题