1

How do I just checkout a branch into an existing folder in a pristine state?

I am working in Windows 10. switched to a new branch of my project, and noticed that some existing (untracked) folders from the other branch were still hanging around. I tried to use:

git clean -fdx

to remove these folders and their files. I got errors such as:

warning: failed to remove Source/Web/node_modules/gulp-sass/node_modules/gulp-ut
il/node_modules/dateformat/node_modules/meow/node_modules/read-pkg-up/node_modul
es/read-pkg/node_modules/load-json-file/node_modules/parse-json/node_modules/err
or-ex

I then tried to use

git reset --hard HEAD

which succeeds, but the folders/files are still there. So how do I just checkout my branch to a pristine state?

The more I use git, the more it just seems designed to actually prevent you from getting work done.

prmph
  • 7,616
  • 11
  • 37
  • 46
  • Is that *actually* the path to a file? – Oliver Charlesworth Mar 07 '16 at 22:38
  • Untracked files will be ignored by every git action. You have to ignore them if you dont want them listed as untacked. Or Remove them by hand like u usually would remove files u dont like. As I said untracked files are not affected by git magic – xetra11 Mar 07 '16 at 22:39
  • @Charlesworth: No it the path to a folder, inside which are other folders and files – prmph Mar 07 '16 at 22:42
  • @xetra: According to the docs at https://git-scm.com/docs/git-clean , the -x option should remove untracked files – prmph Mar 07 '16 at 22:44
  • @prmph thx learned something – xetra11 Mar 07 '16 at 22:46
  • Wondering if this is a Windows path-length limit thing? – Oliver Charlesworth Mar 07 '16 at 22:46
  • @Charlesworth: could well be. The actual path is pretty long: *"C:\Users\User\Documents\Engineering\bma\Source\Web\node_modules\gulp-sass\node_modules\gulp-util\node_modules\dateformat\node_modules\meow\node_modules\read-pkg-up\node_modules\read-pkg\node_modules\load-json-file\node_modules\parse-json\node_modules\error-ex..."* I have updated the title to add the windows context – prmph Mar 07 '16 at 22:48

1 Answers1

1

The length of the error path above is exactly 260 characters. It does seems this is a Windows issue related to the MAX_PATH length issue

Community
  • 1
  • 1
prmph
  • 7,616
  • 11
  • 37
  • 46