I'm working with a developer here who is seeing a weird issue that I've never encountered before. He's working on a repository and needs to pull the latest changes from someone else before he can push. All of his changes are committed.
$ git pull
Cannot pull with rebase: You have unstaged changes.
Please commit or stash them.
Which seems reasonable enough until...
$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 3 and 1 different commit each, respectively.
#
nothing to commit (working directory clean)
Say what?
I've tried git reset --hard HEAD
before pulling, but the pull still fails.
Only one guy is seeing this and he's on a Mac (OSX 10.6.8). Any ideas? I'm about to pull my hair out.
Instead of
git pull
try
git fetch
git rebase -p origin/master
If that doesn't work you can try
git pull --no-rebase
How to check why this message occurs
Make sure you on a branch, not a detached head. Rebasing doesn't work on a detached head.
Run the following commands, the result should be no output.
git update-index -q --ignore-submodules --refresh
git diff-files --ignore-submodules
git diff-index --cached --ignore-submodules HEAD --
Are you working on local filesystem or nfs share?
I had exactly the same problem when I was working on nfs share.
I have added noatime
option to the mount
command and it helped:
mount -t nfs -o noatime,... device dir
for me issue was with files in secure folder
only this command has shown that there are files unstaged
git diff-files --ignore-submodules
de-configure git-crypt and re-encrypt files in work tree
git-crypt lock
You can try for $ git stash then try for git pull.
I had this issue when I tried to rebase a repo owned by root (and I was an unprivileged user).
Looks like there might be a rebase in progress. Try running git rebase --abort
first.
More forceful methods to clean out the local include
Delete all files in the working directory (excluding the .git directory, of course)
git clean -d -x -f
(-d
: directories, -x
: ignored files, -f
: force. Replace -f
with -n
for dry run)
And then follow up with a git reset --hard
and git checkout
.
One more thought is to try a git reset --hard HEAD~N
- i.e resetting a number of commits back, and hoping the pull will work and fast-forward the local.