Just move the files out, which will remove the error. Then after you've done the cleanup, you can move them back in.
Untrack a file from a git branch without switching to the branch
-
18-07-2023 - |
質問
i have some files i don't need to be tracked (mostly uploaded images) However i do need them there... in the working directory
lets call it imageFolder
my .gitignore
didn't have the line **/imageFolder
some time ago...
so some of the images are being tracked...
in the development process i have created a couple of branches with imageFolder
tracked
lets say we have 3 branches
- master
- cleanBranch
- dirtyBranch
right now i have cleanBranch checked out
i fixed this branch with git rm -r --cached imagesFolder
and added **/imagesFolder
to the .gitignore
everything is perfectly fine :) and i am a happy camper...
PROBLEM
when i try to switch to dirtyBranch that still has those images tracked git says
error: The following untracked working tree files would be overwritten by checkout:
imageFolder/img1.jpg
imageFolder/img2.jpg
...
...
Aborting
it does't let me switch to the other branch so i can run git rm -r --cached
and fix the .gitignore
is there a way to untrack those images from a branch that you don't have checked out... or my train of though is wrong and i should take a different approach to resolving this issue
I do need those images to be there in the folder
other than the images the 2 branches look quite different...
i am a git noob take it easy on me hehe :) thank you..
解決