我正在尝试为网站设置生产,测试和开发环境。到了将第一次小改变推向生产的时候。但是,当我尝试这样做时,会出现以下错误:
错误:将覆盖以下未跟踪的工作树文件 合并:
CHANGELOG.txt COPYRIGHT.txt 大段引用 INSTALL.mysql.txt INSTALL.pgsql.txt INSTALL.sqlite.txt INSTALL.TXT LICENSE.TXT MAINTAINERS.txt 的README.txt Upgrade.txt的 杂项/箭头asc.png 杂项/箭头desc.png 杂项/ configure.png 杂项/ draggable.png
文件列表继续,为简洁起见,我省略了它们。
我的生产和开发.gitignore是完全相同的。即,它们如下:
# Ignore configuration files that may contain sensitive information.
sites/*/settings*.php
.htaccess
# Ignore paths that contain user-generated content.
sites/*/files
sites/*/private
<<<<<<< HEAD
=======
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Images #
############
*.jpg
*.gif
*.png
*.pdf
*.tiff
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Ignore default text files
robots.txt
/CHANGELOG.txt
/COPYRIGHT.txt
/INSTALL*.txt
/LICENSE.txt
/MAINTAINERS.txt
/UPGRADE.txt
/README.txt
sites/README.txt
sites/all/modules/README.txt
sites/all/themes/README.txt
>>>>>>> 07326d6660b93c61b407c37a1582a37d5c374905
我该怎么做才能解决这个问题?我认为这个问题与Git如何忽略文件有关。
答案 0 :(得分:1)
如果您想忽略这些文件(如README.txt),而这些文件仍是诸如The following untracked working tree files would be overwritten by merge:
之类的错误消息的一部分,则意味着它们仍被跟踪。
只要被跟踪,.gitignore都不适用。
git rm --cached README.txt
git commit -m "remove README.txt"
如果您在两个分支上都这样做,则可以将其合并为另一个,而不会收到错误消息。