Remote Rejected Main Git
Gitlab remote rejected main -> main (pre-receive hook declined) – Today I added a gitlab project repository in my vscode for the first time.
the command I use is as follows:
cd existing_repo
git remote add origin https://gitlab.com/yourname/test.git
git branch -M main
git push -uf origin main
When I push my file to gitlab, then I get an error that I failed to upload the file to my gitlab repository. The error message that appears is as follows:
neon@NEON:~/Documents/SKY$ git push -uf origin main
Enumerating objects: 13415, done.
Counting objects: 100% (13415/13415), done.
Delta compression using up to 12 threads
Compressing objects: 100% (8595/8595), done.
Writing objects: 100% (13415/13415), 61.11 MiB | 1.18 MiB/s, done.
Total 13415 (delta 4651), reused 13415 (delta 4651)
remote: Resolving deltas: 100% (4651/4651), done.
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To https://gitlab.com/yourname/sky
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.com/yourname/sky'
Therefore, in this article, I will share the solution for this error, to help those of you who experience the same error.
How to Fix This Error
How to Fix This ErrorTo fix the Error remote rejected main -> main (pre-receive hook declined) failed to push some refs to ‘https://gitlab.com/yourname/sky’ it’s very easy. Follow these steps:
- Login to your Gitlab Account
- Select Repository
- Click the Settings menu
- Click the Repository menu
- Click Protected Safes
- Click Allow to force push
- You can see the steps as in the following image:
- Now, repeat the command to push to your gitlab, i use the following command:
git push -uf origin main
- If a command appears, enter your username
- Then enter the password
- If successful you will see something like this;
neon@NEON:~/Documents/TEST$ git push -uf origin main
Enumerating objects: 13415, done.
Counting objects: 100% (13415/13415), done.
Delta compression using up to 12 threads
Compressing objects: 100% (8595/8595), done.
Writing objects: 100% (13415/13415), 61.11 MiB | 1.19 MiB/s, done.
Total 13415 (delta 4651), reused 13415 (delta 4651)
remote: Resolving deltas: 100% (4651/4651), done.
To https://gitlab.com/yourname/test.git
+ d4c842a...3d21d0a main -> main (forced update)
Branch 'main' set up to track remote branch 'main' from 'origin'.
- Done.
Hopefully this article is useful. Have a nice day.
READ MORE:
> Linux for Programmer in 2022 (My Experience)
> How to Choose Best Linux Operating System?
> Lubuntu vs Antix RAM Comparison Linux
> Price Adjustable Height Desk Electric
> 32 bit Linux Distro available in 2022
> Burn ATmega328 Bootloader Using USBasp
> 13-inch Lightweight Laptop Under 1kg 2022
Ive just bumped on browsergames website , have You checked it before? Bye!
I’m more than happy to uncover this web site.
I need to to thank you for ones time just for this fantastic read!!
I definitely enjoyed every part of it and I have you book marked to
see new stuff on your blog.
I аm curious to find out what blog platform yoս’re working with?
I’m experіencing some minor security problems with my latest blօg and I’d like to find something more safe.
Do you hаve any recommendations?
Try WordPress.
just thank you!!!