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.
For all unstaged files in current working directory use: git restore . That together with git switch replaces the overloaded git checkout (see here), and thus removes the argument disambiguation. If a file has both staged and unstaged changes, only the unstaged changes shown in git diff are reverted.
Cannot pull with rebase: You have unstaged changes. Please commit or stash them. Git stash command is kind of commit stored changes to temporary space and clean working copy. Then your working copy will be reverted to HEAD.It is a good place to store uncommitted changes.
You'll often want to do two things: change the commit message, or change the actual content of the commit by adding, removing and modifying files. error: cannot rebase: You have unstaged changes.
To unstage commits on Git, use the “git reset” command with the “–soft” option and specify the commit hash. Alternatively, if you want to unstage your last commit, you can the “HEAD” notation in order to revert it easily. Using the “–soft” argument, changes are kept in your working directory and index.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With