标签:git push error branch currently master git推送失败 sourcetree
git clone xxx@xx 版本后,edit某文件,commit之后,点push,提示报错。
可能有以下原因:
1、权限不够,远程仓库的文件夹(比如/home/git)下面的文件所属用户非git用户,而默认的文件权限通常是644,那么当你用非git用户push的时候,肯定是权限不够的。
解决方法:进入远程仓库的上一级,查看git目录下所有文件的权限,比如:
cd /home/git ls -al
更改git目下所有文件目录的文件主为git:
chown -R git.git /home/git/*
2、如果报错提示如下:
git push
hap@192.168.1.2‘s password:
Counting objects: 21, done.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1010 bytes, done.
Total 11 (delta 9), reused 0 (delta 0)
error: refusing to update checked out branch: refs/heads/master
error: By default, updating the current branch in a non-bare repository
error: is denied, because it will make the index and work tree inconsistent
error: with what you pushed, and will require ‘git reset --hard‘ to match
error: the work tree to HEAD.
error:
error: You can set ‘receive.denyCurrentBranch‘ configuration variable to
error: ‘ignore‘ or ‘warn‘ in the remote repository to allow pushing into
error: its current branch; however, this is not recommended unless you
error: arranged to update its work tree to match what you pushed in some
error: other way.
error:
error: To squelch this message and still keep the default behaviour, set
error: ‘receive.denyCurrentBranch‘ configuration variable to ‘refuse‘.
To git+ssh://hap@192.168.1.2/media/LINUXDATA/working
! [remote rejected] master -> master (branch is currently checked out)
则进入远程仓库
cd /home/git/ssm.git
再执行如下命令
git config ‘receive.denyCurrentBranch‘ warn
标签:git push error branch currently master git推送失败 sourcetree
原文地址:http://stoffsky.blog.51cto.com/3025834/1656000