0

I have a few branches that I want to switch between. The problem I have is there are some changes right away after I switched to that branch due to the line ending problems.

I tried git reset --hard and git clean -f -d before git checkout new_branch but they do not work since files are still in modify state. How can I fix this issue?

It isn't duplicate with git: undo all working dir changes including new files since the answers there doesn't work for me. :(

Community
  • 1
  • 1
Anonymous
  • 9,366
  • 22
  • 83
  • 133

2 Answers2

1

Stash your changes instead:

git stash

If you need them, you can recover them, unlike the above methods - which remove the existence of that file history with extreme prejudice.

Makoto
  • 104,088
  • 27
  • 192
  • 230
0

Definitely the link you mentioned is a good solution for you.

$ git reset --hard
$ git clean -xdf

The first line reset tracked files and the second line remove your untracked files.

Try one more time, and if not, please share error message and the result of git status. It might be helpful to let me help you. :)

Tip, when you try the above commands, you should close editors which open the files you want to reset or clean.

sangheestyle
  • 1,037
  • 2
  • 16
  • 28
  • Those two commands do not help with line endings. After running them, those files are still their (in modified state.) – Anonymous Nov 18 '14 at 09:16
  • All right. If you think it comes from just line ending, you can try followings. a. global settings for line endings: https://help.github.com/articles/dealing-with-line-endings/#global-settings-for-line-endings b. if a doesn't work, you just change line endings into what you want and then make it as a commit. Then, checkout the new branch. – sangheestyle Nov 18 '14 at 09:19
  • Thanks for the link but I want to undo the changes, not change the global configuration. – Anonymous Nov 18 '14 at 09:40