Reputation: 2328
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.
Upvotes: 4
Views: 26131
Reputation: 5148
You can try this:
git rm *.pdf
git commit --amend
I think this should fix your commit locally and then you can push it.
EDIT
Copy your PDFs to another location as the rm
command will delete them from the git directory.
Upvotes: 9
Reputation: 34267
Open terminal, cd
to your git directory and
git log
You will see something like this:
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
Upvotes: 9