Home > front end >  Github with vs Code wants to commit non-exisiting files
Github with vs Code wants to commit non-exisiting files

Time:05-15

I'm facing a weird problem with github in visual studio code. I accidentally tried to commit big files to my remote repo. Then I got the [remote rejected] message. I tried to add the folder to gitignore and unstaged with git reset HEAD^. When committing vs code still wants to upload the big files. Ok, so I deleted all files from the folder, unstaged again, but when I push to github it's still uploading the files and rejecting? How is this possible?? How can I get rid of that?

CodePudding user response:

A very easy solution is to

  • rename the local repository folder to something else, like deprecated
  • git clone the repository, so you will have a fresh repository and the damaged repository
  • make the changes in the fresh clone (override the changed files, remove the deleted files)
  • checkout the branch you were on
  • git add without the large files
  • git commit
  • remove the old, damaged copy

Alternatively, you can run

git reset --soft HEAD~1

However, the [remote rejected] might be caused by a different problem. Maybe you had multiple commits before you have pushed and the large files are not committed in your last commit. Also, it's possible that someone else pushed his/her changes and you need to pull first.

  • Related