tags:

views:

7829

answers:

6

I'm trying to update my repo from a remote branch and keep getting this error when I do a "git pull". I haven't made any local changes, and even if I have I don't need to keep them.

I've tried:

git reset --hard

and I get the same problem

The only thing that seems to work is deleting the offending file and try a git pull again.

I've also tried "git stash" followed by a "git pull". No go.

edit: using PortableGit-1.6.4-preview20090729 so any previous bugs with spurious errors should be fixed.

+9  A: 

Generally speaking, this means you have changes in your local files that haven't been committed to your local repository. You can also see this stackoverflow question for a bit more detail.

codeincarnate
A: 

Worth a try:

Could you set, just for this update, set the config parameter core.trustctime to false?

core.trustctime

If false, the ctime differences between the index and the working copy are ignored; useful when the inode change time is regularly modified by something outside Git (file system crawlers and some backup systems).

VonC
+16  A: 

There's a couple of ways to fix this but I've found git stash works good for me. It temporary puts your local changes into another place. Then you can pull, to grab the latest changes. And then you can get your local changes back.

Just like this:

$ git pull
...
...
file your_file.rb not up to date, cannot merge.

$ git stash
$ git pull
$ git stash pop
manat
A: 

I'm actually having the same issue. It always happen when I update my mirror of the Linux kernel code - which I do not change. Performing a 'git stash' allowed the pull to happen, but now I get the following when I try to do a 'git stash pop'.

"Cannot apply to a dirty working tree, please stage your changes"

When I perform a 'git status' after the pull, I see the following:

linux-2.6:git status
# On branch master
# Changed but not updated:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#   modified:   Documentation/io-mapping.txt
#   modified:   include/linux/netfilter/xt_connmark.h
#   modified:   include/linux/netfilter/xt_dscp.h
#   modified:   include/linux/netfilter/xt_mark.h
#   modified:   include/linux/netfilter/xt_rateest.h
#   modified:   include/linux/netfilter/xt_tcpmss.h
#   modified:   include/linux/netfilter_ipv4/ipt_ecn.h
#   modified:   include/linux/netfilter_ipv4/ipt_ttl.h
#   modified:   include/linux/netfilter_ipv6/ip6t_hl.h
#   modified:   net/ipv4/netfilter/ipt_ecn.c
#   modified:   net/netfilter/xt_connmark.c
#   modified:   net/netfilter/xt_dscp.c
#   modified:   net/netfilter/xt_hl.c
#   modified:   net/netfilter/xt_mark.c
#   modified:   net/netfilter/xt_rateest.c
#   modified:   net/netfilter/xt_tcpmss.c
#
no changes added to commit (use "git add" and/or "git commit -a")

This is very odd behavior - as the only activity that goes on in this repository are pulls from the parent. I never modify files within it.

rbieber
It might be better to ask this as a separate question, instead of posting it as an answer to this older question. Your problem may be different than the OP's, and so you may accept a different solution than he would (if he even still has this problem).
Brian Campbell
Looks like the case insensitivity answer is the one that defines my problem. I'm running OS X (which I forgot to mention).
rbieber
+4  A: 

This sort of problem is frequently caused by trying to pull from a repository that has two filenames that differ only in case. If you are on FAT, NTFS in case-insensitive mode (essentially, any time it's being used under Windows), or HFS+ in case-insensitive mode, and have two files "foobar" and "FOOBAR", then Git will see two distinct files, but the filesystem will only see one, which will cause all kinds of problems. Git will checkout, say, "FOOBAR", and then checkout "foobar", which the filesystem sees as simply replacing the contents of "FOOBAR" but leaving it in place. Now to Git, it appears that "FOOBAR" has been replaced with the contents of "foobar", and "foobar" is gone.

There are two different manifestations of this basic problem. One is when your repository actually contains two files that differ only on case. In this case, you need to work on a case-sensitive file system, or you will need to edit the repository to ensure that no collisions of this sort occur; a case-insensitive file system simply cannot store the contents of this repository.

A different case that you can workaround is when a rename happens that changes the case of the file. Say, for example, that the Git repository contains a rename from "EXAMPLE" to "example". Before Git checks out the new version, it will try and check to make sure it's not overwriting some existing file that you have on your disk. Since it thinks that "example" is a new filename, it will ask the filesystem if it exists, and the filesystem will see "EXAMPLE" and say yes, so Git will refuse to check out the new version since it thinks it will be overwriting untracked files. In this case, if you have no local changes that you care about, a simple git reset --hard <revision-to-checkout> will generally be sufficient to get you past the problem and to the new revision. Just try and remember not to rename files to other names that differ only in case if you're on a case-insensitive file system, as it will cause problems like this.

Brian Campbell
+2  A: 

It might a problem also with file permissions. Git is versioning them too, unless config says otherwise. Just adding those answer for people who has almost but the like problem.

Drachenfels