I'm on Windows using Git version 2.12.2.windows.2.
I have a Git history originally converted from Subversion. I recently realized to that had a file foo.txt~1~
in the repository. (This must have been from an editor in eons past.) I realized this because every time I would clone the repository, Git would immediately tell me that foo.txt
had been modified. Apparently something about the foo.txt~1~
file made Git think that foo.txt
had been modified.
So I figured I'd solve the problem by deleting foo.txt~1~
and making a commit with the log message, "Removed back up text file." Let's call this commit 01234
Then a few commits later, I decided just to get rid of the text file altogether, so I did:
git filter-branch --tree-filter "rm -f foo.txt~1~" --prune-empty HEAD
So now I think I have foo.txt~1~
out of the history. Oddly, the diff for 01234 says that I removed all the lines of foo.txt
and added back all the lines of foo.txt
.
In any case, I want to remove commit 01234 from the history, because there's no point with having a do-nothing commit saying that I removed a backup text file that no longer exists, so I did a git rebase -i 01234~
and selected drop
to get rid of the commit.
Unfortunately Git suddenly stops and says:
Cannot rebase: You have unstaged changes.
Git shows that foo.txt
is modified; it shows that all of the lines of the file have been removed and replaced... with the same lines.
Git says that I can use git checkout -- foo.txt
to discard my changes, but after doing that git status
still shows that foo.txt
is modified.
Git also says that I can use git add foo.txt
to update what will be committed. So I use git add foo.txt
to add the file. It tells me that I have staged changes. So I use git commit -m "Added non-modified text file."
to commit the "changes". Then I did git rebase --continue
again.
That succeeded --- but of course now I have an "Added non-modified text file" commit in the history. So I tried again to git rebase -i 01234~
, then drop
that commit... and the whole cycle starts up again:
Cannot rebase: You have unstaged changes.
Sometimes I want to get rid of Git.
How do I fix this?
P.S. I have a single copy of the original repository before I tried to remove foo.txt~1~
from the history with git filter-branch
, if that helps. But I don't have a copy of the repository before I added single commit removing foo.txt~1~
(commit 01234), and that commit is not the last commit.
P.P.S. I thought this might have something to do with Windows and ~
in the filename, so I tried this on Linux using Git 2.12.2. Exactly the same thing happened.