I've previously been able to undo changes through SourceTree by performing the "Discard" function, which under the hood produces this command:
git -c diff.mnemonicprefix=false -c core.quotepath=false reset -q HEAD -- myproj.csproj
git -c diff.mnemonicprefix=false -c core.quotepath=false checkout HEAD -- myproj.csproj
Suddenly this doesn't work. I do the Discard, no error occurs, refreesh the view, but the files are still "modified". I've then tried to do the same in the command line with the following, same result:
c:\myproject> git reset HEAD
Unstaged changes after reset:
M myproj.csproj
Why is it still listed as an unstaged change?
I've verified that the file is indeed writable (no process is holding a lock)
update
git checkout
didn't work either:
C:\myproject>git checkout myproj.csproj
C:\myproject>git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: myproj.csproj
#
no changes added to commit (use "git add" and/or "git commit -a")
Update 2 Also tried:
git checkout --
git checkout -- .
git checkout HEAD
,none of which solves my problem
update 3 - huge step closer:
Turns out when I do the checkout, the .csproj is indeed reverted to the correct version, but the checked out version uses a different line feed encoding. While the checked-in version has CR-LF (0D-0A) for line feed, the checked-out has only LF (0A). Hence git belives the file to be different on every single line. Why this?
update 4: added the second line of git-commands issued by SourceTree. I didn't notice that the first time around, that's why I thought git reset HEAD
would do anything. This doesn't change the fact that the underlying problem still is CR/LF-related (I think)
summary I never found a solution to the issue, but I "solved" it by checking in the file. My original question didn't contain information that SourceTree indeed issued the correct commands to rollback what I wanted, so most answers here address that issue. The real issue is still unclear, but my main theory is that it was CR/LF related.