I committed and then tried to push files that are too large to upload to GitHub. How can I "clear" this commit in order to be able to make another commit and push it?
I committed and then tried to push files that are too large to upload to GitHub. How can I "clear" this commit in order to be able to make another commit and push it?
You may simply amend your current commit via a soft reset, followed by unstaging the too large files:
# from your feature branch
git reset --soft HEAD~1
This will move the HEAD pointer back one commit, while also staging all the changes from the commit with the too large files. Then, you may simply unstage all too large files, commit again, and then push:
# from feature
git reset -- path/to/toolarge1.ext
git reset -- path/to/toolarge2.ext
git reset -- path/to/toolarge3.ext
# and so on for all large files
git commit -m 'new commit with no large files'
git push origin feature
To keep the work use git reset --soft HEAD~1.
Use git reset --hard if you ever need to remove the changes you've made. You may need to specify the branch however, just use
git reset --hard origin/<branch-name>.