0

I was on branch A and modified some files. I forgot to commit them. Then I switched to branch B and suddenly remembered about files. Now, when I am trying to switch back to branch A it disallows me, saying

The following working tree files would be overwritten by checkout

And giving the list of my modified files.

How to switch and keep files as on disk? I guess if I do --force it will overwrite files with branch versions with is not applicable.

Dims
  • 47,675
  • 117
  • 331
  • 600
  • related: https://stackoverflow.com/q/22053757/1256452 - I usually recommend avoiding `git stash` but this is one thing it actually is pretty good for. :-) – torek Apr 02 '20 at 21:49
  • "I was on branch A and modified some files" and "Then I switched to branch B" without committing the changes. Wasn't `git` suppose to abort this checkout? – iCantC Apr 03 '20 at 05:33

1 Answers1

1

Try using git stash, then git checkout A and then git stash apply

omar jayed
  • 850
  • 5
  • 16