我在Git上有一个Django项目
我对Git不是很满意
我刚刚完成,提交并推送我的功能/22分支
我已提交(在git add .之后)并推动我的主人
所以我的两个分支都是最新的
现在,我想在本地合并母版和要素/22,但发生冲突
即使提交后,我有2个文件在“Unmerge paths”:
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: unblind/migrations/__pycache__/0002_auto_20200124_0904.cpython-37.pyc
both modified: unblind/migrations/__pycache__/0003_auto_20200124_1007.cpython-37.pyc
如果我使用推荐的命令git add呢?
为什么这两个文件没有包含在之前的git add .命令中?
编辑:
$ git merge feature/22
warning: Cannot merge binary files: unblind/migrations/__pycache__/0003_auto_20200124_1007.cpython-37.pyc (HEAD vs. feature/22)
warning: Cannot merge binary files: unblind/migrations/__pycache__/0002_auto_20200124_0904.cpython-37.pyc (HEAD vs. feature/22)
Auto-merging unblind/migrations/__pycache__/0003_auto_20200124_1007.cpython-37.pyc
CONFLICT (content): Merge conflict in unblind/migrations/__pycache__/0003_auto_20200124_1007.cpython-37.pyc
Auto-merging unblind/migrations/__pycache__/0002_auto_20200124_0904.cpython-37.pyc
CONFLICT (content): Merge conflict in unblind/migrations/__pycache__/0002_auto_20200124_0904.cpython-37.pyc
Removing randomization/templates/randomization/_randomisation_edit.html
Automatic merge failed; fix conflicts and then commit the result.
编辑2:
我已经暂时解决了合并问题:
- git checkout 功能/22
- rm(合并master / feature/22时在CONFLICT中提及的所有文件
- git commit -m“删除 *.pyc”
- git检验主程序
- git合并功能/22
- git推送原始主机
但是.pyc仍然被跟踪,在master上运行我的django项目后,如果我做git status:
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: export/migrations/__pycache__/__init__.cpython-37.pyc
modified: parameters/migrations/__pycache__/0003_auto_20200128_1337.cpython-37.pyc
modified: parameters/migrations/__pycache__/0004_auto_20200129_1206.cpython-37.pyc
modified: parameters/migrations/__pycache__/0005_auto_20200305_0810.cpython-37.pyc
modified: parameters/migrations/__pycache__/0006_auto_20200305_1238.cpython-37.pyc
modified: parameters/migrations/__pycache__/0007_auto_20200305_1242.cpython-37.pyc
modified: parameters/migrations/__pycache__/0008_auto_20200305_1428.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0001_initial.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0002_auto_20200129_1206.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0003_auto_20200129_1434.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0004_auto_20200210_1750.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0005_historicalstock_stock.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0006_auto_20200218_1344.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0007_auto_20200218_1359.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0008_auto_20200218_1403.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0009_auto_20200218_1410.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/0010_auto_20200302_1059.cpython-37.pyc
modified: pharmacy/migrations/__pycache__/__init__.cpython-37.pyc
modified: randomization/migrations/__pycache__/0008_auto_20200302_1059.cpython-37.pyc
Untracked files:
(use "git add <file>..." to include in what will be committed)
unblind/migrations/__pycache__/
no changes added to commit (use "git add" and/or "git commit -a")
4条答案
按热度按时间mzaanser1#
将pycache文件存储在git仓库中并不是一个好主意,这些文件是由py_compile module在每次构建时自动生成的。
您可以添加这些文件来解决合并冲突,但是我建议在项目的根目录下使用.gitignore。
这里有一个很好的.gitignore可以添加到您的项目中。
7ivaypg92#
我也遇到过类似的问题。通过将〈/pycache/〉放到.gitignore文件中,然后重新提交更改,解决了这个问题。
gajydyqb3#
您可以忽略项目中的任何
/__pycache__/
文件夹。1.如果您还没有
.gitignore
,可以在项目文件夹中创建一个:project/.gitignore
.1.将
*/__pycache__/*
放入.gitignore
iqih9akk4#
删除那些缓存文件
尽量不要用
保持练习开始添加
.忽略
在开始任何项目之前,将编译过的文件添加到缓存中。