Reclaim space after aborted git add?

I accidentally git added a large (32GB) file to my staging area. After a handful of seconds I noticed (my fans spun up!) and hit CTRL+C. This stopped the process but the ~2GB of space it had used has not been returned to the file system.

How can I reclaim that space? Not that I’m short of a gig or two but having big useless clots of data knocking around somewhere (presumably in my .git folder) bothers me.

  • Move and rename multiple files using git
  • Is it possible to do a shallow git clone based on datetime?
  • Alternatives to git filter-branch when purging a file from Git history?
  • Git tree with selectable nodes in terminal?
  • Is there a way to change the file path for an Rstudio project?
  • git push origin master: 'D:/Projects/TheProject' is not a git command
  • I’ve looked a git clean but that doesn’t look like it will help.

    The files it has added are…

    1.9G    ./objects/pack
    1.9G    ./objects/pack/tmp_pack_lwma1r

    Can I safely delete these?

  • I need to gather review statistics from GitHub on our project
  • Docker-compose: always receive Cannot locate specified Dockerfile
  • How to git clone an SVN repository where all branches are located in root?
  • git push with backdate
  • Git ignoring icon files because of Icon? rule
  • Github Service Hooks: post-receive via PHP
  • One Solution collect form web for “Reclaim space after aborted git add?”


     git reflog expire --expire=now --all
     git fsck --full --unreachable
     git repack -A -d
     git gc --aggressive --prune=now

    This will do a bunch of cleaning on the repo. Specifically, I think git repack is the one that will really solve your problem. The others won’t hurt, though.

    Git Baby is a git and github fan, let's start git clone.