当前位置: 动力学知识库 > 问答 > 编程问答 >

Correct use of git update-index --assume-unchanged

问题描述:

I've got a config file, site.conf, that contains Production settings.

I do not want to track my local updates to it. So, here's what I do:

git update-index --assume-unchanged site.conf

Now I update this with my local database settings, etc.

However, when I try and check out a different, local branch I get the following message:

error: Your local changes to the following files would be overwritten by checkout:

site.conf

Please, commit your changes or stash them before you can switch branches.

Aborting

What am I doing wrong?

网友答案:

You are switching between branches that differ in their site.conf contents. Git will not apply the changes for you: you've been telling Git that your site.conf is unmodified, but Git detects the unexpected local modifications rather than silently overwriting them.

You can either make sure your site.conf is identical in both branches, or forcibly overwrite site.conf and reapply your local changes manually.

分享给朋友:
您可能感兴趣的文章:
随机阅读: