Workaround for "remote:error:refusing to update checked out Branch:refs/heads/master"

Source: Internet
Author: User
Tags using git

When using git push code to the Data warehouse, you are prompted with the following error:

[Remote rejected] master, master (branch is currently checked out)

Error prototypes

remote:error:refusing to update checked out Branch:refs/heads/master

Remote:error:By default, updating the current branch in a Non-bare repository

Remote:error:is denied, because it'll make the index and work tree inconsistent

Remote:error:with What do you pushed, and would require ' git reset--hard ' to match

Remote:error:the work tree to HEAD.

Remote:error:

Remote:error:You can set ' receive.denycurrentbranch ' configuration variable to

Remote:error: ' Ignore ' or ' warn ' in the remote repository to allow pushing into

Remote:error:its Current Branch; However, this isn't recommended unless you

Remote:error:arranged to update their work tree to match the what's pushed in some

Remote:error:other.

Remote:error:

Remote:error:To squelch This message and still keep the default behaviour, set

Remote:error: ' receive.denycurrentbranch ' configuration variable to ' refuse '.

to [email protected]:/var/git.server/.../web

! [Remote rejected] master, master (branch is currently checked out)

Error:failed to push some refs to ' [email protected]:/var/git.server/.../web '

Workaround:

This is because GIT denies the push operation by default, it needs to be set up, and the following code is added after the. git/config file is modified:

[Receive] Denycurrentbranch = Ignore

Unable to view the cause and workaround for files in the push git

Best to use when initializing remote repositories

Git--bare init

Instead of using: Git init

The exact difference between git init and git--bare init: http://blog.haohtml.com/archives/12265

=================================================

If git init initialization is used, the directory of the remote repository also contains the work tree, and when the local repository is push to the remote repository, if the remote warehouse is on a push branch (no problem if it is not in the push branch at that time), The result of the push will not be reflected on the work tree, which is the corresponding file in the remote repository directory or the previous content.

Workaround:

You must use the command git reset--hard to see the content after the push.

Studied for a long time without its solution, and then found a command to make it work: Log in to the remote folder and use

git config--bool core.bare true

It's done.

Workaround for "remote:error:refusing to update checked out Branch:refs/heads/master"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.