0

sometimes while working on git repo i get in that situation where i have added new files after commit then i needed to checkout a previous commit the problem is when doing so i stuck with those new files i have created. so is there any way to clean those new untracked files and still be able to retrieve them after resting the HEAD and back to master?

i tried to stage everything and then stash all of it, running clean, and finally checkout whatever commit i want but this has the drawback of manually trying to unstage all the file that i don't want to be tracked be git

A. AbdElaal
  • 135
  • 7
  • Maybe this will help: https://stackoverflow.com/questions/835501/how-do-you-stash-an-untracked-file – joanis Jan 03 '19 at 20:37
  • See the linked duplicate for a traditional method, but consider (in modern Git at least) using `git worktree add` instead. – torek Jan 03 '19 at 21:15

0 Answers0