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.