Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove committed files from commit

Tags:

git

github

I accidentaly committed some very large PDF files that were well over GitHub's size limit, so when I later pushed, I got an error, and wasn't able to push. Now, I want to remove those files from the commit, without losing them locally, so that I can later add .pdf in .gitignore and commit and push my other changes. Does anyone know how I can do this?

I do not want to undo any changes, or risk to do that.

like image 988
bjornasm Avatar asked Dec 02 '22 16:12

bjornasm


1 Answers

Backup these files first

Open terminal, cd to your git directory and

git log

You will see something like this:

enter image description here

Then copy the commit hash before the addition of these large pdf files and run this command

git reset --soft <good commit hash>

now you can push your local changes

like image 50
Jossef Harush Kadouri Avatar answered Dec 11 '22 15:12

Jossef Harush Kadouri