I have a directory that i want to turn into a git project.
I created a new project in gitlab and then i did the following:
git init
git remote add origin [email protected]:a/b/c.git
git add .
git commit -m "Initial commit"
git push -u origin master
In addition, I created the following .gitignore
file:
*
!*/scripts
!*/jobs
After running git push -u origin master
i got the following error:
Counting objects: 33165, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (32577/32577), done.
Writing objects: 100% (33165/33165), 359.84 MiB | 1.70 MiB/s, done.
Total 33165 (delta 21011), reused 0 (delta 0)
remote: Resolving deltas: 100% (21011/21011), done.
remote: GitLab:
remote: A default branch (e.g. master) does not yet exist for a/b/c
remote: Ask a project Owner or Maintainer to create a default branch:
remote:
remote: https://gitlab.com/a/b/c/project_members
remote:
To gitlab.com:a/b/c.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:a/b/c.git'
What could be the issue? Please advise
How to Fix error: failed to push some refs to Error in Git Using git pull. To send a pull request means to "fetch" new changes made to the remote repo and merge them with the local repo. Once the merging is done, you can then push your own code changes to GitHub.
If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.
To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch).
This is linked to issue 27456 and merge request 6608:
document the need to be owner or have the master permission level for the initial push
So it might be a permission level, not a branch issue.
See commit 81ee443:
You will need to be owner or have the master permission level for the initial push, as the master branch is automatically protected.
I had this issue for quite some time as well. Tried different things, but it did not work. The owner of the GitLab repository of my company changed my status from "Developer" to "Maintainer" and it finally worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With