在Git中合并python文件时会发生错误.请分享您的想法.如何删除所有pyc文件并合并内容.从存储库中提取更新时会发生此错误.那些pyc文件经常更新.当我从存储库中提取更新时,每次都会发生错误
error: The following untracked working tree files would be overwritten by merge:
addressbook/views.pyc
allauth/account/admin.pyc
allauth/account/auth_backends.pyc
allauth/account/context_processors.pyc
allauth/account/forms.pyc
allauth/account/management/__init__.pyc
allauth/account/urls.pyc
allauth/account/views.pyc
allauth/exceptions.pyc
allauth/socialaccount/adapter.pyc
allauth/socialaccount/admin.pyc
allauth/socialaccount/app_settings.pyc
allauth/socialaccount/context_processors.pyc
allauth/socialaccount/forms.pyc
allauth/socialaccount/helpers.pyc
allauth/socialaccount/providers/base.pyc
allauth/socialaccount/providers/facebook/forms.pyc
allauth/socialaccount/providers/facebook/locale.pyc
allauth/socialaccount/providers/facebook/provider.pyc
allauth/socialaccount/providers/facebook/urls.pyc
allauth/socialaccount/providers/facebook/views.pyc
allauth/socialaccount/providers/google/provider.pyc
allauth/socialaccount/providers/google/urls.pyc
allauth/socialaccount/providers/google/views.pyc
allauth/socialaccount/providers/linkedin/provider.pyc
allauth/socialaccount/providers/linkedin/urls.pyc
allauth/socialaccount/providers/linkedin/views.pyc
allauth/socialaccount/providers/oauth/__init__.pyc
allauth/socialaccount/providers/oauth/client.pyc
allauth/socialaccount/providers/oauth/provider.pyc
allauth/socialaccount/providers/oauth/urls.pyc
allauth/socialaccount/providers/oauth/views.pyc
allauth/socialaccount/providers/oauth2/__init__.pyc
allauth/socialaccount/providers/oauth2/client.pyc
allauth/socialaccount/providers/oauth2/provider.pyc
allauth/socialaccount/providers/oauth2/urls.pyc
allauth/socialaccount/providers/oauth2/views.pyc
allauth/socialaccount/providers/twitter/provider.pyc
allauth/socialaccount/providers/twitter/urls.pyc
allauth/socialaccount/providers/twitter/views.pyc
allauth/socialaccount/signals.pyc
allauth/socialaccount/urls.pyc
allauth/socialaccount/views.pyc
allauth/urls.pyc
crispy_forms/base.pyc
crispy_forms/bootstrap.pyc
crispy_forms/exceptions.pyc
crispy_forms/helper.pyc
crispy_forms/layout.pyc
crispy_forms/layout_slice.pyc
crispy_forms/utils.pyc
feeds/views.pyc
lettertemplate/forms.pyc
lettertemplate/views.pyc
quorum/forms.pyc
quorum/views.pyc
registration/admin.pyc
registration/forms.pyc
registration/models.pyc
registration/urls.pyc
registration/views.pyc
rosetta/polib.pyc
rosetta/poutil.pyc
rosetta/signals.pyc
rosetta/storage.pyc
rosetta/urls.pyc
rosetta/views.pyc
Please move or remove them before you can merge.
Aborting
Run Code Online (Sandbox Code Playgroud)
.pyc文件可能不应该被跟踪,因为正如你所看到的,它们会不断变化.通常,构建产品不会存储在git中.如果你有选项我会在上游存储库中解开它们.
如果这不是一个选项,您唯一的选择是移动或删除您的本地.pyc文件.您可以使用以下命令执行此操作(注意:这假定您要删除当前目录中或下面的所有 .pyc文件.
find . -iname '*.pyc' -exec rm {} \;
Run Code Online (Sandbox Code Playgroud)
执行此操作后,您应该可以进行合并,因为不会覆盖本地文件.
发生此错误的原因是您正在跟踪.pyc存储库中的文件(您不应该这样做).这可能git add .是你应该做的是删除所有.pyc文件git rm,然后再次合并的结果.Git不会抱怨,因为它不会通过.pyc本地版本复制存储库文件.
正如尼克所建议的那样,添加.pyc和其他无法跟踪全局(或存储库级别).gitignore的文件可能是一个好主意.如果这样做,git add .将不会自动添加这些文件.查看GitHub的官方建议.gitignore文件列表.