Let’s say I was doing stuff in a local directory. I added a large file, I commit and push, but I get an error stating that the file is too large. If I didn’t care about this file making its way to the Github repo, how can I go about removing it from the commit without ruining the rest of my progress? I tried deleting the file, re-adding and re-commiting, but I get the same error when I push. So far my workaround has been to copy everything in the directory except .git to a different, temporary folder, revert to origin/master, and then replace everything back in with the changes I want. I haven’t found a good solution for just… ignoring the large file or removing it from the commit, nothing I’ve found online has worked and the commit always just fails because of the large file.

Edit: hey everyone thanks for all the replies! I appreciate it, I’ll have to test out these sometime.

  • Ordoviz@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    4 days ago

    Make sure your working tree is clean (if not, commit or stash your changes), then run

    $ git rm ./that_one_big_file
    $ git history fixup deadbeef
    

    Replace deadbeef with the commit that introduced that_one_big_file.

    For more complex history editing tasks, see git rebase in depth.

    • ComicalMayhem@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      4 days ago

      Someone else recommended rm before but I hadn’t seen git history fixup deadbeef command before. I’ll test this out sometime, thanks for the suggestion and the link!

      Edit: I assume I used the commit hash for git history fixup?