-2

I have a git repo with say 10-20 commits. I added some files of 1gb and commited the change. I forgot to track these 1gb files using git lfs.

Now when I tried to push it to github it failed cause of the big size. Now I want git to completely forget about this change. So I made a copy of the repo and to undo the changes.

I did git reset --hard hash_value but still the size of the .git directory is 1gb something.

Which suggest that It knows about the change/files that were added, and still I can't push the changes.

Is there some way to tell git to completely forget about the files made in/after some specified commit (in this case the last commit made)?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • The dupe is incorrect. As for the post, git push is not performed successfully yet. – 273K Mar 29 '23 at 14:20

1 Answers1

0

but still the size of the .git directory is 1gb something.

If you have successfully removed the commit with the command git reset --hard <hash_value>, the next step is running the garbage collector for searching and deleting unreachable/unreferenced <hash_value>.

git gc --prune=now

Still I can't push the changes.

You might need to force push after removing the commit

git push --force-with-lease
273K
  • 29,503
  • 10
  • 41
  • 64