3

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?

5
  • Did you do a merge and you failed? Or, are you in the middle of a merge? Commented Aug 7, 2013 at 9:30
  • @Atropo maybe I have merged and not committed because the files seems to be staged. But I thought I could reset staged files using git reset HEAD <file>? Commented Aug 7, 2013 at 9:34
  • post the output of git status Commented Aug 7, 2013 at 9:36
  • git 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.aspx Commented Aug 7, 2013 at 9:39
  • Do you want to reverty the changes? Try these : git checkout -- <filename> or git reset --hard origin/master or git reset --hard origin/[branch-name] Commented Aug 7, 2013 at 9:54

3 Answers 3

2

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
Sign up to request clarification or add additional context in comments.

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.
Ok, how can I reset modified tracked files from my local repo?
you are correct, I use both os x and windows in this repo so I emailed github and they told me to put *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?
GitHub recommends git config --global core.autocrlf input on OS X and git config --global core.autocrlf true on Windows.
0

try this out.

i think the file is in staged section.

first do

   git reset HEAD <file>...

then do

  git checkout <file>...

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.