22
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git pushしたときのエラー

Posted at

pushしたときに、下記のようなエラーでできない場合
参考サイトまんまですが。。。

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v origin develop:develop 
Pushing to hoge@xxx.xxx.xxx.xxx:/path/to
remote: error: refusing to update checked out branch: refs/heads/develop        
remote: error: By default, updating the current branch in a non-bare repository        
remote: error: is denied, because it will make the index and work tree inconsistent        
remote: error: with what you pushed, and will 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 is not recommended unless you        
remote: error: arranged to update its work tree to match what you pushed in some        
remote: error: other way.        
remote: error:         
remote: error: To squelch this message and still keep the default behaviour, set        
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.        
To hoge@xxx.xxx.xxx.xxx:/path/to
 ! [remote rejected] develop -> develop (branch is currently checked out)
error: failed to push some refs to 'hoge@xxx.xxx.xxx.xxx:/path/to'
Completed with errors, see above

設定確認

$ git config --get-all core.bare
false

変更

$ git config --bool core.bare true

再度確認

$ git config --get-all core.bare
true

git config --add receive.denyCurrentBranch ignore で対応するのは良くないらしい。

さらに、下記のようなエラーの場合、

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v origin develop:develop 
Pushing to hoge@xxx.xxx.xxx.xxx:/path/to
To hoge@xxx.xxx.xxx.xxx:/path/to
 ! [rejected]        develop -> develop (non-fast-forward)
error: failed to push some refs to 'hoge@xxx.xxx.xxx.xxx:/path/to'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Completed with errors, see above

git pullしたら、なおる。

おしまい。


参考サイト

22
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?