Git rebase失败,显示“合并时以下文件的本地更改将被覆盖”。但是没有进行过本地更改?

127
这是我尝试将错误修复分支合并到主分支准备推送到上游时的记录。自从创建错误修复分支以来,一些上游更改已被拉入主分支,现在它拒绝进行变基。它抛出错误的文件在打开时没有被diff。没有添加、删除或重命名任何文件。没有被忽略的内容,也没有未跟踪、暂存或未暂存的内容。我完全不知道为什么变基失败了。我使用的是OS X 10.6.6和git 1.7.4。
.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git rebase bug586-test master-test
First, rewinding head to replay your work on top of it...
Applying: - comiitting code related to api permissions
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
    inc/data.inc
    templates/apipermissions_tpl.inc
    templates/currencies_tpl.inc
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0001 - comiitting code related to api permissions

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".



.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git status
# Not currently on any branch.
nothing to commit (working directory clean)



.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git rebase --abort
HEAD is now at 5efccf1 - comiitting code related to api permissions



.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git log -n10 --oneline
5efccf1 - comiitting code related to api permissions
a8a5ee4 Style changes for IE
cfca618 Style changes for IE
8a69de6 Style changes for IE
8946585 - comiitting code related to api permissions - fixed an html error in the currencies template
5fba0a9 Merges the 1.11b branch bugfixes and changes into trunk
ef57049 Andrew Commiting on Blakes behalf on changes he made to transfers; Also an Indue GW balance fix; debitcarupload fix for LSN
69e4313 Fixed an issue with Support From email
9058fb6 Sets the svn property svn:eol-style to LF, to enforce unix style line endings
240839e Fixes up a lot of the whitespace issues.



.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git checkout bug586-test 
Switched to branch 'bug586-test'



.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git log -n10 --oneline  
b7b1f8a Resolves #586, Postback on deposit
5fba0a9 Merges the 1.11b branch bugfixes and changes into trunk
ef57049 Andrew Commiting on Blakes behalf on changes he made to transfers; Also an Indue GW balance fix; debitcarupload fix for LSN
69e4313 Fixed an issue with Support From email
9058fb6 Sets the svn property svn:eol-style to LF, to enforce unix style line endings
240839e Fixes up a lot of the whitespace issues.
cf27b6f - bug that came up with transferring. The transfer page had a hidden field called to, which was taking precedence over cards and usercard which would throw the system out a bit
7c21a81 Fixes #603, new add transaction form, journalled.
01e6292 Removes a pile of resource forks
880c5bc - bug that came up with transferring. The transfer page had a hidden field called to, which was taking precedence over cards and usercard which would throw the system out a bit



.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git rebase master-test bug586-test
First, rewinding head to replay your work on top of it...
Applying: Resolves #586, Postback on deposit
Using index info to reconstruct a base tree...
<stdin>:52: trailing whitespace.
                'name' => 'Invoice Transfer Out', 
<stdin>:175: trailing whitespace.

warning: 2 lines add whitespace errors.
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
    templates/deposit_tpl.inc
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0001 Resolves #586, Postback on deposit

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".



.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git rebase --abort
HEAD is now at b7b1f8a Resolves #586, Postback on deposit

你应该分别发布git状态的内容,gitignore的内容以及相关目录中的ls结果,这样更易于阅读。至少这可能会有所帮助。 - Kzqai
你有任何crlf设置或其他吗?Rebase不应该创建这样的脏工作树。而git status在rebase失败时可能会有帮助。它拒绝在有脏树的情况下运行;我们知道在开始之前它是干净的。当存在本地修改时,状态才会引起问题。 - Cascabel
你确定 git rebase 命令的参数顺序吗?第一个 ref 是要 rebase 到的,而可选的第二个 ref 是首先要 checkout 的。也许你应该交换它们。 - Laurent Pireyn
2个回答

221

这是我先前提问时关于git问题的答案。

我使用的是mac系统,这个神秘的配置更改似乎解决了所有未暂存修改的问题,即使此时没有任何更改。

git config --global core.trustctime false

我想这与Windows文件时间、Linux文件时间和Mac文件时间之间的差异有关,如果你知道的话,请随意评论。

更新:这篇博客文章解释了正在发生的事情。


2
谢谢!我永远也想不到这个。 - Christopher Pickslay
1
这里也一样,Chris - 我肯定想知道是什么让这个对我起作用了。 - karlbecker_com
1
我正在使用git-svn在SuSE上提交到一个不同时区的SuSE svn服务器。无论是什么解释,这对我也解决了问题。 - Jonathan Hartley
5
这里是可能导致问题的解释 http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/#! 看起来与revisiond后台进程有关。 - schmunk
我确实看到了这个问题。我有点不同意,主要是因为这个问题是在2011年7月20日狮子发布之前发布的。我甚至在问题中说我使用的是OSX 10.6。这表明这个问题存在于osx版本功能之前。 - jhogendorn
显示剩余8条评论

62
关于Joshua Hogendorn的回答:在使用git工作库时保持Xcode打开似乎会导致这些问题。这甚至导致了一种情况,即git提交了我认为已经存储(并且之后仍然有)但是Xcode在重新建立期间直接写入了文件系统。
因此:如果想要安全起见,请关闭Xcode项目,然后再使用git工作库,那么您可能不需要设置core.trustctime false。

4
我尝试了...并且对我有用!在执行衍合操作之前,请关闭Xcode。浪费了很多时间却一事无成。谢谢! - Nicolas Lauquin
我使用的是Aptana Studio 3,虽然我遇到了与上述相同的错误。当我退出Aptana时,rebase就起作用了。几天前,我关闭了Aptana的git集成。要么它没有真正关闭,要么我应该重新启动Aptana。 - Bill Hoag
3
在使用Visual Studio 2013打开项目时遇到了相同的问题,关闭项目后问题得到解决。 - Mohammad Dehghan
1
我曾经遇到过类似的问题,在Windows上进行rebase操作时...我在bash shell中运行rebase,但同时打开了Visual Studio和SourceTree...我关闭了这两个应用程序后,rebase操作就顺利进行了。谢谢。 - Gavin Hope
3
总的来说,这似乎是在变基期间文件被锁定的问题。对我而言,是由于正在运行webpack --watch - Marc Stober
显示剩余3条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接