125

Here is my transcript from trying to merge my bugfix branch onto my master branch in preparation to push it upstream. There have been some upstream changes pulled into master since the bugfix branch was created, and it now refuses to rebase.

The files it throws errors on are not diffed when opened. no files have been added, removed or renamed. Nothing is ignored and nothing is untracked or staged or unstaged. I'm completely stumped as to why the rebase is failing.

I'm on OS X 10.6.6 and 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
Kzqai
  • 22,588
  • 25
  • 105
  • 137
jhogendorn
  • 5,931
  • 3
  • 26
  • 35
  • You should post the contents of a git status, the contents of your gitignore, and ls in the directories in question seperately, so it's more clearly readable. That might help some, at least. – Kzqai Feb 22 '11 at 05:16
  • Do you have any crlf settings or anything? Rebase shouldn't be creating a dirty work tree like that. And the `git status` that might be helpful is when the rebase fails. It refuses to run with a dirty tree; we know it's clean before you start. It's the status when there *are* local modifications that is causing a problem. – Cascabel Feb 22 '11 at 16:58
  • Are you sure about the order of the parameters to git rebase? The first ref is the one to rebase to, while the optional second ref is the one that will be checked out first. Maybe you should swap them. – Laurent Pireyn Feb 23 '11 at 08:24

2 Answers2

217

This is the same answer as another one of my questions re git troubles.

I'm on a mac, and this obscure config change seemed to fix all my woes regarding unstaged changes when there were none.

git config --global core.trustctime false

I think it's to do with differences between windows file times, linux file times and mac file times. who knows, feel free to comment if you do.

Update: This blog post explains what's going on, sort of.

Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
jhogendorn
  • 5,931
  • 3
  • 26
  • 35
  • 2
    Thanks! I never would have figured this out. – Christopher Pickslay Oct 28 '11 at 22:01
  • 1
    Same thing here Chris - I'd definitely like to know what caused this to work for me. – karlbecker_com Dec 21 '12 at 22:30
  • Unfortunately this did not work for me. Quitting Xcode - _even though the files Git complained about were not in the project_ - did help. – Uncommon May 16 '13 at 22:47
  • 1
    I'm on SuSE using git-svn to commit to a SuSE svn server in a different time zone. Whatever the explaination, this fixed the problem for me too. – Jonathan Hartley Aug 23 '13 at 12:49
  • 5
    Here's an explanation of what might be the cause http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/#! Looks like it has to do with a revisiond background process. – schmunk Nov 25 '13 at 08:08
  • I did see that actually. I'm inclined to disagree somewhat, mainly because this question was posted pre lion's release date of July 20, 2011. I even say in the question that I'm on OSX 10.6. Which indicates that the issue existed prior to the version functionality of osx. – jhogendorn Nov 27 '13 at 06:10
  • A `git revert` of a range of commits also failed with the same kind of error for a colleague of mine, and this fixed it. – gitaarik Apr 18 '14 at 10:49
  • @jhogendom you're a hero! – felipecrv Apr 22 '14 at 05:47
  • I hit this on Windows today. Doing `git rebase --abort` and then re-trying the rebase worked for me. – Drew Noakes Dec 20 '16 at 09:14
  • This fixed worked for me but `git rebase --continue` refused to continue because no files were changed. I fixed that by doing: `touch empty_file && git add empty_file`. Then after the rebase I had to do `git rm empty_file` – Jon Abrams Mar 17 '17 at 21:15
  • @Jon Abrams I just did `git rebase --abort`, changed the setting, then re-ran `git rebase` – Jason Goemaat Oct 19 '17 at 21:06
  • @JonAbrams I'd be careful with that, because when I did that, I actually lost the changes from one of my commits (which then cascaded and caused the rest of the rebase to have errors). The command above did work for me after aborting. – ACVM Mar 20 '18 at 19:12
  • It happened to me when I traveled between time zones in between my commits. I was the only one working on the branch and it was on the same laptop too. Thanks, this fixed it! – markgarg Feb 22 '21 at 16:46
62

With regards to Joshua Hogendorn's answer: it seems to me that leaving Xcode open while working on the repository with git leads to these problems. It even led to a situation where git committed something that I thought to have stashed (and still had afterwards) but Xcode just wrote to the filesystem right during the rebase.

So: Close your Xcode project before you work on the repo with git if you want to be safe, and then you probably don't need the core.trustctime false setting.

jhogendorn
  • 5,931
  • 3
  • 26
  • 35
user132837
  • 944
  • 7
  • 5
  • Perhaps you had some kind of "automatically save file every N minutes" setting active in your IDE? Do not do that. – Mikko Rantalainen Apr 29 '13 at 06:23
  • 4
    I tried… and worked for me ! Close xcode before doing a rebase. Waste some many time for nothing. Thanks ! – Nicolas Lauquin Nov 29 '13 at 18:15
  • I had the same errors as above although I'm using Aptana Studio 3. When I exited Aptana, the rebase worked. I had turned off Aptana's git integration a few days ago. Either it didn't really turn off or I should have restarted Aptana. – Bill Hoag Jan 09 '14 at 17:03
  • Using NetBeans and had same problem too. This one solved it. Thanks! – Liglo App Nov 06 '14 at 13:13
  • 3
    Faced the same problem when the project was open in Visual Studio 2013. Closing the project solved the issue. – Mohammad Dehghan May 10 '15 at 15:52
  • Same problem using Rubymine – GuiGS Jul 27 '16 at 14:37
  • 1
    I had a similar problem, during rebase, on Windows... running the rebase from a bash shell, but had Visual Studio open and SourceTree open... I close both of those other apps and the rebase progressed without issue. Thx. – Gavin Hope Sep 21 '16 at 11:01
  • 3
    More generally this seems like a problem with files being locked during a rebase. For me it was `webpack --watch` running. – Marc Stober Dec 12 '16 at 16:10