Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Changes blocked by files exceeding the file size limit #3527

Closed
dkrishnan7hub opened this issue Jun 2, 2024 · 2 comments
Closed

Error: Changes blocked by files exceeding the file size limit #3527

dkrishnan7hub opened this issue Jun 2, 2024 · 2 comments
Labels

Comments

@dkrishnan7hub
Copy link

We are getting the following error: Changes blocked by files exceeding the file size limit

remote: Resolving deltas: 100% (492/492), done.
remote:
remote: Push contains files exceeding the size limit:
remote:
remote:   31c3dd7f2bf911dc68461ec6cbff002d9cce017d
remote:       Size: 179064597B
remote:
remote: 1 file found exceeding the size limit of 100000000B
remote:
remote: pre-receive: error: Changes blocked by files exceeding the file size limit, try --help

And interesting the file thats exceeding the size limit is within the .git folder
\.git\objects\31\c3dd7f2bf911dc68461ec6cbff002d9cce017d

Could you please advice how we can increase the file size limit or resolve this problem?

Thanks in advance, cheers!

@johannesHarness
Copy link
Collaborator

Hey @dkrishnan7hub, that's a good question 🚀

Regarding the following statement:

... the file thats exceeding the size limit is within the .git folder
.git\objects\31\c3dd7f2bf911dc68461ec6cbff002d9cce017d

The feature only blocks files above a configured size limit from being pushed to the remote repository, but doesn't prevent you from creating and committing such files locally.

In your case, you most likely created and committed such a limit exceeding file locally, and where you were trying to push it, gitness blocked it (I assume the folder you were referring to was your local clone, as the .git folder indicates it's not a bare repo)

There's a few ways you can resolve your problem:

1. Remove the file that's exceeding the file limit

In case the file was committed by accident, or isn't really needed, you can remove the file to resolve the problem.
For that you'll have to remove the file from every commit in which the file exceeds the limit, which might be harder depending on how far back it is in your local commit history. In your case, it seems there's only one version of the file that's exceeding the size limit (e.g. 31c3dd7f2bf911dc68461ec6cbff002d9cce017d)

Some useful commands:

  • find commits on your branch that added the object: git log --find-object=31c3dd7f2bf911dc68461ec6cbff002d9cce017d
  • find the file path(s) of the object for a given commit: git ls-tree -r COMMIT_SHA | grep 31c3dd7f2bf911dc68461ec6cbff002d9cce017d
  • If the object was introduced with the most recent commit, you can just remove the file and then git commit --amend to update the latest commit. However, if the object was introduced further in your commit history, it can get more tricky to do manually.

After you've removed ALL occurrences of the file (e.g. git log --find-object=31c3dd7f2bf911dc68461ec6cbff002d9cce017d returns an empty response), you should then be able to push your branch without any issues.

2 Decrease the file size

If you can't remove the file, but it's possible to reduce it's size, you can follow the same steps as above, but instead of removing the file from ALL commits where it exceeds the limit, you'll have to update it.

3. Increase the file size limit for the repo

If the file is necessary and can't be removed or decreased in size, you can update the max file size limit of the repository.
This will only update the limit for that specific repository, other repositories will still maintain their previous limit (100MB by default).
There's no UI support as of now, so you'll have to use the following API:

curl '{GITNESS_ENDPOINT}/api/v1/repos/{REPO_PATH}/+/settings/general' \
-H 'Authorization: XXX' \
-X PATCH \
--data '{
    "file_size_limit": 1000000
}'

NOTE: limit is in Bytes, above is the default value

You can then verify the new limit has been set correctly by making the following API call:

curl '{GITNESS_ENDPOINT}/api/v1/repos/{REPO_PATH}/+/settings/general' \
-H 'Authorization: XXX'

@johannesHarness
Copy link
Collaborator

Closing this issue for now, feel free to reopen if there's a related issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants