Home > Software design >  Undo changes on Git not commited without erase the files - I added my computer filesby mistake, I ne
Undo changes on Git not commited without erase the files - I added my computer filesby mistake, I ne

Time:11-17

I was studying Git and I did a big mistake that I need to reverse without destroy my system.

I added a lot of system files to my "changes" as you can see in the image below: Image from VsCode with the list of added files

Also this file is part of the git status command git status of the files

I want to revert it without erase the files. I did it once and it changed the full config of the system and all the time I open the vsCode it appear to me to commit the changes again

Please help!! More infos: I tried those commands already:.

 git checkout -f
 fatal: You are on a branch yet to be born

 git stash
 You do not have the initial commit yet

 git reflog
 fatal: your current branch 'master' does not have any commits yet

CodePudding user response:

You can do this with git reset.

git reset

This will tell git to un-add all the files you added, but it won't change or delete any files.

DO NOT RUN git reset --hard. Git reset --hard will discard all of the files you added, which means it'll delete a bunch of stuff.

Side note: it looks like you made a git repository in your home directory by accident. If you prefer, you can just delete the hidden .git folder inside your home directory. This get rid of the git repository without affecting anything else.

  • Related