I have modified files in my git repo, but git checkout <file> does not work and neither does git reset --hard. There are no error messages whatsoever. I also have one *.orig and git clean -f does not remove that file either?
3 Answers
If git checkout and git reset --hard are leaving files in a modified state, it can be caused by git modifying line-endings or whitespace.
Run git diff --ignore-space-change to see if there are non-whitespace changes.
If the *.orig file is not tracked by git, but is ignored, you must add the -x parameter so that git doesn't use the standard ignore rules.
git clean -f -x
4 Comments
git clean only removes untracked files, but git status shows that the file is tracked. The modified status is definitely whitespace, see Dealing with line endings.*text=auto in my .gitattributesfile but if I remove that line again my changed are gone. Maybe this is off topic but what is the best settings for line endings when working on both os x and windows?git config --global core.autocrlf input on OS X and git config --global core.autocrlf true on Windows.To me looks like you're in the middle of a merge, that's why you have the .orig files. Diff tools create .orig files to keep a backup of merged files.
If you want to abort the merge you can do, but only if you have git >= 1.6.1
git reset --merge
Or, starting from version 1..7.4, you do:
git merge --abort
mergeand you failed? Or, are you in the middle of amerge?git reset HEAD <file>?git statusgit status -s M README.md M src/NKA.Core/Domain/PageTypes/AreaPage.cs.orig M src/NKA.Web/App_Browsers/AdapterMappings.browser M src/NKA.Web/App_Browsers/IE6.browser M src/NKA.Web/Templates/ArticleList.aspx M src/NKA.Web/Templates/Page.aspxgit checkout -- <filename>orgit reset --hard origin/masterorgit reset --hard origin/[branch-name]