Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve unstaged changes not shown by "git status"

Tags:

git

Consider

$ git status
On branch chore/nbsp-fix-2
nothing to commit, working directory clean
$ git rebase -i master
Cannot rebase: You have unstaged changes.
Please commit or stash them.

How do I work out what the unstaged changes are that are preventing git from rebasing?

Some background: Someone managed to add files with a non-breaking space (%A0) in the name. This has caused problems with the repository. The files show up as not tracked and git thinks the repository is dirty — a similar problem.

The technique I was using to correct the problem is to create a new branch before those changes were made and cherry-pick the few commits after those changes. Unfortunately I am now in this situation. I can imagine there is some other file or other remnant of that problem preventing me from moving forward. I am now in this position after cherry-picking the single commit following the bad file names.

I'm looking for suggestions for getting past this problem. What is rebase seeing that status does not see?

like image 465
Bill Door Avatar asked Feb 24 '15 01:02

Bill Door


1 Answers

Turns out git rebase is a shell script in /usr/libexec/git-core/git-rebase, grepping for "have unstaged changes" in that dir gets exactly one hit, in git-sh-setup, in this function:

require_clean_work_tree () {
    git rev-parse --verify HEAD >/dev/null || exit 1
    git update-index -q --ignore-submodules --refresh
    err=0

    if ! git diff-files --quiet --ignore-submodules
    then
        echo >&2 "Cannot $1: You have unstaged changes."
        err=1
    fi

[ ... ]

and rebase does invoke that. So, to answer

What is rebase seeing that status does not see?

your question, try git diff-files.

like image 64
jthill Avatar answered Oct 02 '22 09:10

jthill