Git push origin master error, workaround

Source: Internet
Author: User
Tags reset using git

Today, an error occurred while using git to push local code to the remote server:

whl@whl-desktop:/work2/recvdsrc$ git push Origin master klha@klha.net ' s password:counting objects:44, done.
Compressing objects:100% (24/24), done.
Writing objects:100% (25/25), 13.10 KiB, done. Total (delta), reused 0 (Delta 0) remote:error:refusing to update checked out Branch:refs/heads/master remote:er Ror:by default, updating the current branch in a non-bare repository Remote:error:is denied, because it'll make the I Ndex 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 ' O R ' 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 it work tree to match what do you pushed in so
Me 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 KLHA@KLHA.NET:/HOME/KLHA/RECVDATA/RECVDSRC! [Remote rejected] master, master (branch is currently checked out) error:failed to push some refs to ' klha@klha.net:

 /home/klha/recvdata/recvdsrc '


this is because git denies the push operation by default and needs to be set up and modified. Git/config Add the following code:

Follow the prompts to execute the command to resolve the issue:

git config receive.denycurrentbranch ignore



The following references:

Http://blog.sina.com.cn/s/blog_55465b470100s638.html

It's best to use git--bare init when initializing a remote repository instead of: Git init

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), Then the result of push will not be reflected on the work tree, that is, in the remote repository directory of the corresponding files or the previous content, you must use git reset--hard to see the content after the push.

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.