harness / gitness

Gitness is an Open Source developer platform with Source Control management, Continuous Integration and Continuous Delivery.
https://gitness.com
Apache License 2.0
31.89k stars 2.78k forks source link

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

Closed dkrishnan7hub closed 3 weeks ago

dkrishnan7hub commented 1 month ago

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 commented 1 month ago

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:

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 commented 3 weeks ago

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