Remove locked files from commit

I accidentally committed several very large PDF files that were well above the size limit of GitHub, so when I later clicked, I got an error and could not click. Now I want to remove these files from the commit, without losing them locally, in order to subsequently add .pdf to .gitignore and commit and push other changes. Does anyone know how I can do this?

I do not want to undo any changes or risk doing so.

+4
source share
2 answers

Back up these files first

Open terminal , cd to git directory and

 git log 

You will see something like this:

enter image description here

Then copy commit hash before adding these large pdf files and run this command

 git reset --soft <good commit hash> 

now you can push local changes

+8
source

You can try the following:

 git rm *.pdf git commit --amend 

I think this should fix your commit locally, and then you can push it.

EDIT

Copy your PDF files to another location when the rm command removes them from the git directory.

+7
source

All Articles