【发布时间】:2016-03-22 23:41:49
【问题描述】:
我在一个 Drupal 网站上与其他几个人合作,我们正在对 Git 进行版本控制。我们设置了一个包含我们提交的本地 Git 存储库。
在同事推送了一些更新,我提取并合并到本地 dev 分支后,我开始遇到以下问题:
user@server:/var/www/Intranet/sites/intranet/modules/custom$ git checkout dev
error: The following untracked working tree files would be overwritten by checkout:
themes/bigcompany/panels/layouts/radix_bryant_flipped/radix-bryant-flipped.png
themes/bigcompany/panels/layouts/radix_bryant_flipped/radix-bryant-flipped.tpl.php
themes/bigcompany/panels/layouts/radix_bryant_flipped/radix_bryant_flipped.inc
Please move or remove them before you can switch branches.
Aborting
当我尝试结帐到其他失败的分支并且我实际上被困在当前分支中时,通常会出现上述问题。
参考this 问题,有一个建议是我的问题与 gitignore 文件有关。但是,我的 .gitignore 文件没有任何内容表明我的主题目录的任何部分都应该被忽略,如下所示:
# .gitignore for a standard Drupal 7 build based in the sites subdirectory.
# Drupal
files
settings.php
settings.*.php
# Sass.
.sass-cache
# Composer
vendor/
# Migrate sourec files
modules/custom/haringeygovuk_migrate/source_data
如上所述,我尝试在任何分支中执行 git checkout 失败并显示上述消息。我决定用-f 开关强制它并成功切换到我的目标分支,但我丢失了几百行代码 - 我很想避免继续前进。
我在 Linux-Ubuntu VirtualBox 上工作,我的同事更喜欢在 WAMP 设置中工作,并使用 Git Bash 终端模拟器来执行 Git 命令。 环境差异会导致这些严重问题吗?
我该如何解决这个问题?
【问题讨论】:
标签: linux windows git git-bash