My situation is that a massive, 2GB file has been inadvertently pushed to our remote git repo on Azure DevOps. I noticed this when reviewing the pull request.
I cannot have a file that big in my repo and need to delete it. From the history as well. I don't want someone cloning the repo to pull down a pointless 2 GB file
The checkin is still on a branch. It has not been merged to the master. But it is on the remote repo
As long as nobody else is using this branch, is it safe for my user to do a git reset on this branch? I'm told that a git revert will not delete the file from the history and that I need a git reset.
Is this my path to a fix?
I'm told that a git revert will not delete the file from the history and that I need a git reset. Is this my path to a fix?
Mostly, yes. The user should rewrite their branch such that the large file no longer exists in any commit on that branch. There are a few different ways to do this, and reset
is one of them. Presumably their are other changes on the branch that the user still needs, so you can make a commit that deletes the file, and then interactive rebase and squash the delete commit into the commit that added the file. Regardless of what method you use to rewrite the branch, you'll need to simply force push that branch out to update the PR.
Note there are some caveats here:
gc
or prune that commit from your repo, test it, and share the instructions with the rest of your users.Tip: In AzureDevOps, under Project Settings->Repositories, there are options for the entire system and also each individual repo, where you can set the Maximum file size that can be pushed. I recommend you enable that setting to a sensible option. I would also recommend setting it a little too low rather than too high, since you can temporarily disable the setting in the rare instance they need to purposefully push something above the limit. (Of course, this assumes it will be rare enough that an admin temporarily disabling and reenabling afterwards won't be a bottleneck or annoyance to developers.)