Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I've a repository for my dotfiles and went to push changes from a branch only to encounter...
$ git push
Enumerating objects: 46, done.
Counting objects: 100% (46/46), done.
Writing objects: 100% (46/46), 3.20 MiB | 1.52 MiB/s, done.
Total 46 (delta 0), reused 0 (delta 0)
To gitlab.com:auser/dotfiles.git
! [remote rejected] kimura -> origin/kimura (deny updating a hidden ref)
! [remote rejected] master -> origin/master (deny updating a hidden ref)
error: failed to push some refs to 'git@gitlab.com:auser/dotfiles.git'
This thread suggests its because pull requests made on origin and links to a blog post with solution of how to skip this, although I do not explicitly have refs/pull in the path thats being rejected so it may be a different issue but I couldn't find much info on this so figured I try the proposed solution and updated my config to...
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@gitlab.com:auser/dotfiles.git
fetch = +refs/heads/*:refs/heads/*
fetch = +refs/tags/*:refs/tags/*
fetch = +refs/change/*:refs/change/*
pushurl = git@gitlab.com:auser/dotfiles.git
push = +refs/heads/*:refs/remotes/origin/*
[submodule "oh-my-zsh/.oh-my-zsh"]
url = https://github.com/robbyrussell/oh-my-zsh
active = true
[branch "master"]
remote = origin
merge = refs/heads/master
pushRemote = origin
[branch "kimura"]
remote = origin
merge = refs/heads/kimura
fetch = +refs/heads/*:refs/heads/*
fetch = +refs/tags/*:refs/tags/*
fetch = +refs/change/*:refs/change/*
But the problem persists. My branches are...
$ git branch -a
* kimura
master
remotes/origin/kimura
remotes/origin/master
The host I'm trying to push from is where I started the repo before mirroring to Gitlab.
–
–
–
The problem was:
I cloned a remote repo mobile into a folder, then, I made modifications on the code, and when I tried to push, instead of pushing the local repo mobile to the remote one, I was trying to push its parent
The right way was to open git bash inside the local repo you have cloned and execute the right commands, this may be your problem too.
The SO thread you're referencing concerns a repo cloned as --mirror. This is most probably not your situation.
A mirror clone is one that is intended to be a local hub for pushing, and not for direct work (e.g., it doesn't have a working tree, active branch etc.). Regular repo clones fetch branch xyz into, say, origin/xyz - to avoid changing the branch you're working on from under your feet. In mirror clones you want to fetch xyz into xyz directly. I suspect the 'protected branch' error you're getting is due to exactly this: git is protecting you from fetching into the branch you're currently working on.
I'm guessing the correct config for you would be -
[remote "origin"]
url = git@gitlab.com:auser/dotfiles.git
fetch = +refs/heads/*:refs/remotes/heads/*
fetch = +refs/tags/*:refs/remotes/tags/*
fetch = +refs/change/*:refs/remotes/change/*
pushurl = git@gitlab.com:auser/dotfiles.git
push = +refs/heads/*:refs/heads/*
[branch "kimura"]
remote = origin
merge = refs/heads/kimura
fetch = +refs/heads/*:refs/remotes/heads/*
fetch = +refs/tags/*:refs/remotes/tags/*
fetch = +refs/change/*:refs/remotes/change/*
And please verify that you actually need the push key. I don't see why the defaults won't be enough for a regular clone.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.