Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

Git error: ! [remote rejected] main -> main (pre-receive hook declined)

Git error:

davy_@DESKTOP-2I1L6PU MINGW64 /d/xampp81/htdocs/foodshop (main)
$ git push -uf origin main
Enumerating objects: 12491, done.
Counting objects: 100% (12491/12491), done.
Delta compression using up to 8 threads
Compressing objects: 100% (9964/9964), done.	
Writing objects: 100% (12491/12491), 170.55 MiB | 2.76 MiB/s, done.
Total 12491 (delta 2152), reused 12491 (delta 2152), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (2152/2152), done.
remote: GitLab: You are attempting to check in one or more blobs which exceed the 100.0MiB limit:
remote:
remote: - 6bfcacdc692350a9c53caf39a4c3d590ab2bbdef (118 MiB)
remote: To resolve this error, you must either reduce the size of the above blobs, or utilize LFS.
remote: You may use "git ls-tree -r HEAD | grep $BLOB_ID" to see the file path.
remote: Please refer to https://gitlab.com/help/user/free_push_limit and
remote: https://gitlab.com/help/administration/settings/account_and_limit_settings
remote: for further information.
To https://gitlab.com/******/******.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.com/******/******.git'

I already tried to unprotect my main branch and re-push but still get similar error.

ref: https://stackoverflow.com/questions/28318599/git-push-error-pre-receive-hook-declined

0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

The error message you're encountering indicates that you are trying to push a file that exceeds GitLab's 100MB file size limit. To resolve this issue, you have a couple of options:

  1. Reduce the size of the file: If possible, you can try to compress or otherwise reduce the size of the file that is over 100MB.

  2. Use Git Large File Storage (LFS): Git LFS is designed to handle large files by storing them outside of your main repository and only keeping pointers to the files in your repository. Here’s how you can set up Git LFS and push your large file:

Step-by-Step Solution Using Git LFS

  1. Install Git LFS:

    • If you haven't already installed Git LFS, you can do so by following the instructions on the Git LFS website.
  2. Initialize Git LFS in your repository:

    git lfs install
    
  3. Track the large file(s) with Git LFS:

    • Replace path/to/largefile with the path to your large file.
    git lfs track "path/to/largefile"
    
  4. Add the .gitattributes file to your repository:

    • Git LFS will create a .gitattributes file to track the large files. Add this file to your repository.
    git add .gitattributes
    
  5. Add and commit your large file(s):

    git add path/to/largefile
    git commit -m "Add large file using Git LFS"
    
  6. Push your changes to the remote repository:

    git push origin main
    

Example

Here’s an example of how you might handle a large file named largefile.zip:

  1. Install Git LFS:

    git lfs install
    
  2. Track the large file:

    git lfs track "largefile.zip"
    
  3. Add the .gitattributes file:

    git add .gitattributes
    
  4. Add and commit the large file:

    git add largefile.zip
    git commit -m "Add large file using Git LFS"
    
  5. Push the changes:

    git push origin main
    

By following these steps, you should be able to push your large file to GitLab without encountering the pre-receive hook error.

davy_yg's avatar
Level 27
	davy_@DESKTOP-2I1L6PU MINGW64 /d/xampp81/htdocs/foodshop_single (main)
	$ git lfs install
    Updated Git hooks.
    Git LFS initialized.

    davy_@DESKTOP-2I1L6PU MINGW64 /d/xampp81/htdocs/foodshop_single (main)
    $ git lfs track /d/xampp81/htdocs/foodshop_single
    Tracking "D:/xampp81/htdocs/foodshop_single"

    davy_@DESKTOP-2I1L6PU MINGW64 /d/xampp81/htdocs/foodshop_single (main)
    $ git add .gitattributes

    davy_@DESKTOP-2I1L6PU MINGW64 /d/xampp81/htdocs/foodshop_single (main)
    $ git add /d/xampp81/htdocs/foodshop_single

    davy_@DESKTOP-2I1L6PU MINGW64 /d/xampp81/htdocs/foodshop_single (main)
    $ git commit -m "Add large file using Git LFS"
    On branch main
    nothing to commit, working tree clean

    davy_@DESKTOP-2I1L6PU MINGW64 /d/xampp81/htdocs/foodshop_single (main)
    $ git push -uf origin main
    Locking support detected on remote "origin". Consider enabling it with:
    $ git config lfs.https://gitlab.com/******/******.git/info/lfs.locksverify true
    Enumerating objects: 12494, done.
    Counting objects: 100% (12494/12494), done.
    Delta compression using up to 8 threads 
    Compressing objects: 100% (9966/9966), done.
    Writing objects: 100% (12494/12494), 170.50 MiB | 2.57 MiB/s, done.
    Total 12494 (delta 2155), reused 12489 (delta 2153), pack-reused 0 (from 0)
    remote: Resolving deltas: 100% (2155/2155), done.
    remote: GitLab: You are attempting to check in one or more blobs which exceed the 100.0MiB limit:
    remote:
    remote: - 6bfcacdc692350a9c53caf39a4c3d590ab2bbdef (118 MiB)
    remote: To resolve this error, you must either reduce the size of the above blobs, or utilize LFS.
    remote: You may use "git ls-tree -r HEAD | grep $BLOB_ID" to see the file path.
    remote: Please refer to https://gitlab.com/help/user/free_push_limit and
    remote: https://gitlab.com/help/administration/settings/account_and_limit_settings
    remote: for further information.
    To https://gitlab.com/******/******.git
    ! [remote rejected] main -> main (pre-receive hook declined)
    error: failed to push some refs to 'https://gitlab.com/******/******.git'

I tried still getting the same error.

Any idea how to solve this problem?

Please or to participate in this conversation.